lib/featuredimage/finder.rb
# Find first featured image that is matching criteria from web page.
# And return it as Magick::ImageList.
# If the featured image does not exist return nil.
Find first featured image that is matching criteria from web page.
And return it as Magick::ImageList.
If the featured image does not exist return nil.
Find first featured image that is matching criteria from web page . And return it as Magick :: ImageList . If the featured image does not exist return nil .
def biggest(url, cond)
			agent = Mechanize.new
			page = agent.get(url)
			max_size = Size.new(0, 0)
			max_imagelist = nil
			page.search("img").each{|elm|
				src = elm.attributes["src"].value
				begin
					data = download_image(agent, src)
					imagelist = Magick::ImageList.new
					imagelist.from_blob(data)
					size = Size.new(imagelist.columns, imagelist.rows)
					if featured_image?(cond, size)
						if max_size < size
							max_size = size
							max_imagelist = imagelist
						end
					end
				rescue Mechanize::ResponseCodeError
				end
			}
			max_imagelist
		end
def biggest ( url , cond ) agent = Mechanize . new page = agent . get ( url ) max_size = Size . new ( 0 , 0 ) max_imagelist = nil page . search ( "img" ) . each { | elm | src = elm . attributes [ "src" ] . value begin data = download_image ( agent , src ) imagelist = Magick :: ImageList . new imagelist . from_blob ( data ) size = Size . new ( imagelist . columns , imagelist . rows ) if featured_image? ( cond , size ) if max_size < size max_size = size max_imagelist = imagelist end end rescue Mechanize :: ResponseCodeError end } max_imagelist end
Find first featured image that is matching criteria from web page.
Find first featured image that is matching criteria from web page .
# ignore Mechanize::ResponseCodeError
url
<not_specific>
cond
<not_specific>