user285594
user285594

Reputation:

How to tell iframe to resize the image link to a given width and height

I have 1 iframe and having youtube link, but i need also to show same iframe image. Once i pass image links with width and height it does not do the resizing.

How to do that?

Html:

<iframe width="257" 
        height="194" 
        src="http://www.youtube.com/embed/adadfad" 
        frameborder="0" 
        allowfullscreen=""></iframe>

jQuery:

    divID.find('iframe').attr('src', function(i, val) {
      return 
      "<img src=http://img.youtube.com/vi/" + 
         match[2] + 
       "/2.jpg width=300 height=200/>"
    }); 

Upvotes: 1

Views: 5977

Answers (2)

user285594
user285594

Reputation:

This worked.

root.find('iframe').ready(function(){
  root.find('iframe')
      .contents()
      .find('body')
      .html("<img src=http://img.youtube.com/vi/" + match[2] + "/2.jpg />");
  root.find('iframe')
      .contents()
      .find('img')
      .css({'width':'225px', 'height':'175px'});
});

Upvotes: 3

Rashmi Kumari
Rashmi Kumari

Reputation: 530

If u want to resize the image u can just use the normal jquery.

$('img').css('width','300px');
     $('img').css('height','300px');

Upvotes: 1

Related Questions