Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IFrame Image Resizing

In any modern browser, when you visit an image url (eg, http://i.imgur.com/xrM9q.jpg), it automatically resizes that image and gives you the option to "zoom in" with a little magnifying glass. This is not always the case with an iframe:

<iframe src='http://i.imgur.com/xrM9q.jpg'> </iframe>

If you link an iframe to an image, Firefox will give this nice behavior: it starts out behaving like max-width: 100%; max-height: 100%, then you can click on it to make it big.

However, in Chrome, the image is just full-size. Try opening this example in Chrome and Firefox.

How do I get Chrome to handle images "smartly"? That is to say, have the default behavior show a magnifying glass cursor and provide auto-resizing?

(To clarify: I want this to work in a Chrome extension. The only solution I've come up with so far is to put a content script on all pages and manually change styling on images on the page. That solution sucks, so I'm hoping for a method that is less hacky and doesn't effect every page the user visits)

like image 413
Chuck Avatar asked May 14 '12 18:05

Chuck


1 Answers

Try making the iframe refer to another html file and in that html file put the img tag with the width and height constraint. I think it will work on most browsers this way.

like image 145
Joelio Avatar answered Oct 23 '22 22:10

Joelio