diff --git a/lib/twitter/entities.rb b/lib/twitter/entities.rb index 899d05032..70540d80b 100644 --- a/lib/twitter/entities.rb +++ b/lib/twitter/entities.rb @@ -31,7 +31,8 @@ def hashtags? # @note Must include entities in your request for this method to work # @return [Array] def media - entities(MediaFactory, :media) + extended_entities = entities(MediaFactory, :media, :extended_entities) + extended_entities.empty? ? entities(MediaFactory, :media) : extended_entities end memoize :media @@ -84,9 +85,10 @@ def user_mentions? private # @param klass [Class] - # @param key [Symbol] - def entities(klass, key) - @attrs.fetch(:entities, {}).fetch(key.to_sym, []).collect do |entity| + # @param key2 [Symbol] + # @param key1 [Symbol] + def entities(klass, key2, key1 = :entities) + @attrs.fetch(key1.to_sym, {}).fetch(key2.to_sym, []).collect do |entity| klass.new(entity) end end