Sha256: b908808afdc6dfd75522e3db6d82eba2005bcafdce3b2ae08df851640243115d

Contents?: true

Size: 862 Bytes

Versions: 4

Compression:

Stored size: 862 Bytes

Contents

# frozen_string_literal: true
require 'agave/utils/meta_tags/base'

module Agave
  module Utils
    module MetaTags
      class Image < Base
        def build
          return unless image

          [
            og_tag('og:image', image.url),
            card_tag('twitter:image', image.url)
          ]
        end

        def image
          @image ||= seo_field_with_fallback(:image, item_image)
        end

        def item_image
          item && item.fields
                      .select { |field| field.field_type == 'image' }
                      .map { |field| item.send(field.api_key) }
                      .compact
                      .find do |image|

                        image.width && image.height &&
                          image.width >= 200 && image.height >= 200
                      end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
agave-client-0.1.3 lib/agave/utils/meta_tags/image.rb
agave-client-0.1.2 lib/agave/utils/meta_tags/image.rb
agave-client-0.1.1 lib/agave/utils/meta_tags/image.rb
agave-client-0.1.0 lib/agave/utils/meta_tags/image.rb