# frozen_string_literal: true

module Api::PagesHelper
  def image_url(page, size = 'medium')
    path = page.primary_image.try(:content).try(:url, size)
    return '' if path.blank?

    URI.join(ActionController::Base.asset_host, path).to_s
  end

  # List all images required for api/featured.json
  def images_src_set(page)
    %w[medium_square medium large].each_with_index.collect do |size, index|
      (url = image_url(page, size)).present? ? (url.to_s + " #{index + 1}x") : nil
    end
  end
end

# frozen_string_literal: true

module Api::PagesHelper
  def image_url(page, size = 'medium')
    path = page.primary_image.try(:content).try(:url, size)
    return '' if path.blank?

    URI.join(ActionController::Base.asset_host, path).to_s
  end

  # List all images required for api/featured.json
  def images_src_set(page)
    %w[medium medium_square large].each_with_index.collect do |size, index|
      (url = image_url(page, size)).present? ? (url.to_s + " #{index + 1}x") : nil
    end
  end
end

Revert "Changed the order of images in the srcset attrib"
Revert "Changed the order of images in the srcset attrib"

This reverts commit 33e665a8c0cb7ce36f3d5121fa0a7c164b6994e8.
