Responsive web design & responsive images
#1
Posted 09 August 2011 - 07:17 PM
apeisa: splitted this topic. To see history go: Any pointers on creating a mobile version of a site?
#2
Posted 10 August 2011 - 06:24 AM
#3
Posted 10 August 2011 - 06:37 AM
#4
Posted 10 August 2011 - 08:28 AM
I really like responsive designs, but as Adam said they are not always ideal. Consider image heavy frontpage of news site for example. Loading that amount of big images and scaling them down (or hiding) in css is not ideal at all (when good mobile optimized site would be just news headers and maybe one or two featured images).
I completely understand where you are coming from Apeisa. How I handle that is with a (max-width or min-width) media query call. When the site scales down to a certain width, I have a different set of css called. That redesigns parts of the site to suit the new browser widths
#5
Posted 10 August 2011 - 09:01 AM
#6
Posted 10 August 2011 - 09:29 AM
#7
Posted 10 August 2011 - 09:53 AM
If using javascript is acceptable, I suppose all the <img> tags could easily have their src attribute changed to reflect the screen width and one of a few different image sizes. Though the src attribute would probably have to point to some common placeholder initially since the browser initiates the image http request (I think?) right after it sees the <img> tag. Or of course, the <img> tags could just be written with javascript. But of course such a site would lack images if the client had no javascript... so less than ideal.
#8
Posted 10 August 2011 - 10:54 AM
My thought is that CSS image resizing would be really inefficient for an image heavy site... it doesn't seem acceptable. Is there a responsive solution for this? I can think of some hacks to achieve it, but am interested in best practices and am not yet full up-to-speed with RWD.
As far as I know all the current solutions pretty much hacks and not clear winner here. See this for example: http://filamentgroup..._image_sizing/.
For image heavy sites I would just go with separate mobile site and 100% freedom for markup.
#9
Posted 10 August 2011 - 12:29 PM
That's a good link, though I'm not wild about their solution... <base> tags are something to be avoided, IMO. And something you'd have to be very careful with applying to an existing site. Even if inline javascript isn't kosher, wouldn't something like this be much more straightforward?
<script>img('/path/to/large.jpg', '/path/to/small.jpg', 'unicorn stampede');</script>
<noscript><img src='/path/to/large.jpg' /></noscript>
Then there would be that img() function in an included javascript file:
function img(large, small, alt) {
var src = $(window).width() >= 480 ? large : small;
document.write("<img src='" + src + "' alt='" + alt + "' />");
}
#10
Posted 10 August 2011 - 01:25 PM
#11
Posted 10 August 2011 - 03:36 PM
#12
Posted 10 August 2011 - 03:45 PM
Still amazed about elegance of this (and I really mean elegance, since all other solutions seems to be very very messy...). Usually it is that simplest solutions are hardest to find...
---
The downfall is mobile devices that don't support javascript... they'll get the full size image when we want them to get the small image.
Well... I think that the super nice thing about this is that you can even choose your default. You might as well serve small image inside <noscript> and serve high quality images only for js-enabled and big resolution browsers. Think about this:
<script>img('Big.jpg', 'Small.jpg', 'Alt');</script>
<noscript><img src='Small.jpg' /><p><a href='Big.jpg'>Click to see bigger image</a></p></noscript>
[Edit by Adam] Gluing doubple posts together. Again
#13
Posted 10 August 2011 - 03:54 PM
http://www.jamesfair...php_and_jquery/
As a side note, the ajax/PHP side of this article is pretty insane from a resources and/or security standpoint. If they aren't caching the files to disk, then someone could kill the server by making a a few hundred image requests in a minute (simplest DDOS attack ever). If they are caching the images, then they could feasibly end up with thousands of files per image, and fill up the server's hard drive pretty quickly.
#14
Posted 10 August 2011 - 04:03 PM
I think that we have clear winner here
#16
Posted 11 August 2011 - 03:41 PM
You just need this in your html:
<noscript data-large='Koala.jpg' data-small='Koala-small.jpg' data-alt='Koala'><img src='Koala.jpg' alt='Koala' /></noscript>
Tiny jQuery snippet does the heavy lifting and creating all the img tags.
EDIT: Tested only with high-end desktop browsers and with my android. My HTC Desire HD default browser fails to load small images, since it fakes it's resolution (same problem with other solutions that rely on screen.width). But other browsers work just fine.
#17
Posted 12 August 2011 - 08:26 AM
One other possible thing to do would be to use jQuery to hook into the $(window).resize(function() { ... }); and change the src attribute consistent with the window size. But that's probably only useful when dragging small to large (unlikely or impossible on a mobile device), as there's little reason to replace the large image once it's loaded. On the other hand, it does make the effect easier to see in a demo.
#19
Posted 18 August 2011 - 02:32 PM
If responsive images in this context were a really common need, I would probably just code the image plugin to output it in the manner we needed, with noscript tags. But I don't think it's quite common enough to warrant providing that option, yet. I would be more inclined to take a CSS percentage resizing approach for less defined images like those in a wysiwyg field.
#20
Posted 19 August 2011 - 05:51 AM
well, haven't built a responsive site so far, only read a couple of articles, so i'm not too savey on that topic:)
Commonly i would predefine (or tell the client) to only use 2 sizes of images to be inserted in the content, because many different sized images would look odd, i think.
i assume loading time would definitely benefit, if you only need to load the small version of an image for the mobile site.
thanks, jan
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users












