I’m building a responsive website. The logos and images that I add will be responsive (using the Flexible Image action or similar). But what happens if the client uses the CMS to add images to the site - how do I make these responsive?
That’s where things get interesting or awkward depending your viewpoint.
In your CSS you’re going to have to set a series of overrides depending on your device width. Doing things like making the images within column text with:100% !important; float: none !important; on say narrow devices like phones where images are not already 100% width.
On 23 Aug 2013, at 12:01, “Mark” email@hidden wrote:
I’m building a responsive website. The logos and images that I add will be responsive (using the Flexible Image action or similar). But what happens if the client uses the CMS to add images to the site - how do I make these responsive?
In vanilla FW (without any CMS), this can be added though the extended dialog for the image. Just add an entry in the tab with class as the name, and flexImage as the value.
If you are using the WebYep image action, you will need to use the action’s extended dialog, like so:
How are you guys doing this? To get this code to work I have to make sure
the image is enclosed in an html element that responds to the
layout, instead of inserting an image into a run of text, to limit the
image from expanding uncontrollably.
–
Ernie Simpson
.flexImage {
width: auto !important;
height: auto !important;
max-width: 100% !important;
}
The principal of that code is that the image shouldn’t expand past its pixel dimensions. It will scale down indefinitely, but if the image file is 700px wide, it should stop growing at 700px.
It’s strange if it isn’t working for you, mind if I have a link?
I just tested this here with an image I made to be 200px x 300px. When I applied this class to the image, even if I bumped up the “width” attribute of the img tag to 800, the image stayed 200px wide. I couldn’t even make it larger by adding width:800px to the img tag’s “style” attribute. Now if you are scaling massive images (such as in your big heavy-equipment-for-sale site) then you will get the result you describe, where the image grows like topsy unless you constrain it within another sized element.
Walter
On Aug 23, 2013, at 1:07 PM, Caleb Grove wrote:
.flexImage {
width: auto !important;
height: auto !important;
max-width: 100% !important;
}
Here is an example file which shows the difference - scale the page (or
view it on devices) and you’ll see the difference in behavior.
There is also a third method I’ve been futzing with but that I won’t get
into just now.
–
Ernie Simpson
On Fri, Aug 23, 2013 at 1:26 PM, Caleb Grove email@hidden wrote:
Ernie,
The principal of that code is that the image shouldn’t expand past its
pixel dimensions. It will scale down indefinitely, but if the image file is
700px wide, it should stop growing at 700px.
It’s strange if it isn’t working for you, mind if I have a link?
I think these are both handsome ways to handle the scaling, and which one you choose will be a function of whether you want a layout that absolutely scales to a smaller screen, or that degrades gracefully to a smaller screen. These are not always precisely the same thing.
I use that on most of my responsive sites. While it doesn’t make your images flexible width, what it does do is automatically create different sizes of the same image and serve them to the correct devices.
Let’s say that you had a huge graphic that was 2000px wide on a flexible width website, which was set span the entire browser width. The last thing you want to do is require a mobile user with spotty 3g and data caps to download that gigantic graphic.
That is where http://adaptive-images.com steps in. When the first mobile user visits your website, it will use an image scaling feature in Apache to generate a version of the graphic that is 480px wide (you decide on the breakpoints). Then, it will cache that image on your server and serve it to any mobile devices instead of the 2000px wide version.
As you can imagine, if you are using large graphics, this will greatly speed up the loading time and will result in happier users that are more likely to stick around.
But that requires me to use FW rather than a client being able to add images to their site using their CMS and the images being responsive/flexible size?
Like I said, I’ve never use Surreal before, so these are just guesses. If anyone has a FW website using Surreal, and would be willing to share the login credentials with me, I could do some better testing (click on my name above to go to my profile and get my email address).
From what I’m seeing on Surreals website, there are two ways to add images to a site:
Have the dev (you) include the image in the HTML, then set it to be editable using class="editable". In Freeway, it would look like this:
Insert a graphic item on the page. Size it to the dimensions that you like.
Right-click on the image, click on “Extended”, and go to the <img> tab.
Add a new entry with “class” as the name and “editable” as the value.
If you want the image to be flexible width, make sure that you have added this before the </head> tag:
<style type="text/css">
.flexImage {
width: auto !important;
height: auto !important;
max-width: 100% !important;
}
</style>
Then instead of just using “editable” in the value field, use “flexImage editable” (with the space in-between).
Have the clients add the images through the rich-text editor. If you have included the block of code above before the </head> tag, you somehow have to ensure that class="flex image" is somehow added to the <img> tag. I don’t know if you can do this with Surreal, or how you would do it.