I am having trouble retrieving the largest image from a feed. I can only get my code to return the first image found on each entry, rather than the largest.
Feedjira::Feed.add_common_feed_entry_element("media:thumbnail", :value => :url, :as => :media_thumbnail_url)
Feedjira::Feed.add_common_feed_entry_element("media:thumbnail", :value => :height, :as => :media_thumbnail_height)
Feedjira::Feed.add_common_feed_entry_element("media:thumbnail", :value => :width, :as => :media_thumbnail_width)
Feedjira::Feed.add_common_feed_entry_element("media:content", :value => :url, :as => :media_content_url)
Feedjira::Feed.add_common_feed_entry_element("media:content", :value => :type, :as => :media_content_type)
Feedjira::Feed.add_common_feed_entry_element("media:content", :value => :medium, :as => :media_content_medium)
Feedjira::Feed.add_common_feed_entry_element("media:content", :value => :height, :as => :media_content_height)
Feedjira::Feed.add_common_feed_entry_element("media:content", :value => :width, :as => :media_content_width)
Feedjira::Feed.add_common_feed_entry_element("content")
Feedjira::Feed.add_common_feed_entry_element("image")
feed = Feedjira::Feed.fetch_and_parse(@params[:feed_url][:value])
This is what I have so far, but the problem is, for entries that have multiple images (one smaller thumbnail, and a larger main image), this only pulls the first image found, which is generally the smaller of the two. How do I pull the max size media:content width and height?
Use
Feedjira::Feed.add_common_feed_entry_elementsinstead. This will allow the return an array of elements/images instead of the first element/image matched. Then you'll have to iterate through the array to find the max media size.References: