lib/linkser/objects/html.rb in linkser-0.0.5 vs lib/linkser/objects/html.rb in linkser-0.0.6
- old
+ new
@@ -17,10 +17,11 @@
meta.get_attribute("name").eql? "description"
}) && e.get_attribute("content")
end
def images
+ max_images = @options[:max_images] || 5
Array.new.tap do |images|
if ogp and ogp.image
begin
img_spec = ImageSpec.new(ogp.image)
if valid_img? img_spec.width.to_f, img_spec.height.to_f
@@ -29,10 +30,10 @@
rescue
end
end
nokogiri.css('img').each do |img|
- break if images.length >= 5
+ break if images.length >= max_images
img_src = img.get_attribute("src")
img_src = complete_url img_src, url
img_uri = URI.parse(img_src)
img_ext = File.extname(img_uri.path)
img_name = File.basename(img_uri.path,img_ext)