Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7595513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:41:23+00:00 2026-05-30T21:41:23+00:00

I get with Mechanize a array with every images from a web page with

  • 0

I get with Mechanize a array with every images from a web page with this code:

url = http://www.cnn.com
page = Mechanize.new.get(url)
@images_urls = page.images.map{|img| img.url.to_s }.compact

and I get in my view this images with a block:

<div class="preview">
<% @images_urls.each do |image_url| %>
 <%=  image_tag "#{image_url}" %>
<% end %>
</div>

This array generate urls like e.g.:

<img src="http://i2.cdn.turner.com/cnn/dam/assets/120226120954-mandela-paper-t1-main.jpg" alt="120226120954-mandela-paper-t1-main">
<img src="http://i2.cdn.turner.com/cnn/dam/assets/120226120954-mandela-paper-t1-main.jpg" alt="120226120954-mandela-paper-t1-main">
<img src="http://i.cdn.turner.com/cnn/.e/img/3.0/global/icons/video_icon.gif" alt="Video_icon">
.
.
.

I need a code for remove images less 50px in height and width, then I get

$('.preview img').load(function() {
   var $img = $(this);
   alert ($img.width());
   if ($img.height() < 50 || $img.width() < 50) {
       $img.remove();
   }  
});

I get in alert ($img.width()); the value 0 for every images…So remove every images for this condition.

The images have values ​​greater than zero 0!!

Why?

Edited Problem Fixed

The problem is that I’m using Fancybox and the code goes after Fancybox callback

onComplete

Thank you Rob W

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:41:25+00:00Added an answer on May 30, 2026 at 9:41 pm

    Try this snippet for determine if the image was loaded, Here ..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm mapping a array with this code: url = http://www.cnn.com page = Mechanize.new.get(url) images_url
require 'rubygems' require 'mechanize' agent = Mechanize.new page = agent.get(http://google.com/) This simple script works
I am using Mechanize gem to parse html content. Firing this on terminal, agent.get(http://www.example.com/).search(.sidebar-deal-excerpt).first
I'm using Mechanize for scraping images url then I'm looking http://mechanize.rubyforge.org/Mechanize/Page/Image.html for to know
I'm trying to search yellowpages.com via the Perl module WWW::Mechanize. $mech->get( http://www.yellowpages.com ); $mech->form_name(
I'm using the Rails session to store a cookie_jar I get from Mechanize. This
Using Mechanize with Ruby I get a certain file using agent.get('http://example.com/foo.torrent') , with FileUtils
I have the following html code on the page received by mechanize (agent.get): <div
I get a URL from a user. I need to know: a) is the
I am trying to get WWW::Mechanize to login to Yahoo using https; however, it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.