Sha256: 7ae5a54eac018bc2f629171c0467ffa145472f0c225e84332e60c0d595e26f26

Contents?: true

Size: 614 Bytes

Versions: 6

Compression:

Stored size: 614 Bytes

Contents

module Pageflow
  class ImageFileUrlTemplates
    def call
      styles.each_with_object({}) do |style, result|
        result[style] = replace_extension_with_placeholder(
          UrlTemplate.from_attachment(example_file.attachment, style)
        )
      end
    end

    private

    def replace_extension_with_placeholder(url)
      url.gsub(/.JPG$/, '.:processed_extension')
    end

    def styles
      example_file.attachment_styles(example_file.attachment).keys + [:original]
    end

    def example_file
      @example_file ||= ImageFile.new(id: 0, file_name: ':basename.:extension')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pageflow-17.0.4 app/models/pageflow/image_file_url_templates.rb
pageflow-17.0.3 app/models/pageflow/image_file_url_templates.rb
pageflow-17.0.2 app/models/pageflow/image_file_url_templates.rb
pageflow-17.0.1 app/models/pageflow/image_file_url_templates.rb
pageflow-17.0.0 app/models/pageflow/image_file_url_templates.rb
pageflow-16.2.0 app/models/pageflow/image_file_url_templates.rb