images resizing in Omega

Events happening in the community are now at Drupal community events on www.drupal.org.
ricksta's picture

Is there a typical best practices way to handle the resizing of images in the Omega subtheme?

R

Comments

If you mean resizing as in

tinarey's picture

If you mean resizing as in responsive theme you'd declare the sizes separately for each width you want to use in css/YOURTHEME-alpha-default-LAYOUTWIDTH.css in your theme (and make sure it's actually named like your theme). So if you wanted to declare the image size for the narrow layout, use YOURTHEME-alpha-default-narrow.css.

If you mean resizing as in image processing (like resizing user uploaded images for thumbnails) that's not actually a theme thing but would be handled by a module (like image styles in D7: /admin/config/media/image-styles).

Does this help you at all?
Cheers, Tina

CSS may not cut it.

drew reece's picture

Declaring the sizes in CSS is a pain for anything other than background images (i.e. known aspect ratio). Images within content will be in too many aspect ratios to get any practical level of control with css.

You can serve full size files use relative sizing & hope that the browser will scale them ok to fit the container & add some JS to help IE scale cleanly…
http://unstoppablerobotninja.com/entry/fluid-images/
You need to override core's image handling to remove the image width & height from the Only local images are allowed. tags

I suspect ricksta may be thinking about 'responsive images', e.g. only sending small files to mobile devices. Sending full versions to screens that can handle them etc.
http://unstoppablerobotninja.com/entry/responsive-images/
module to integrate it http://drupal.org/project/responsive_images

There doesn't seem to be a really solid solution as far as I can see, I made a module to remove the dimensions & add the JS for 'fluid images', but I still need to test it with many browsers.

I'd love to hear what people are doing, is the responsive images module the best we have until the HTML spec incorporate an answer?

thanks

ricksta's picture

That's the approach I was asking for. I had no idea there was already a Drupal module that could do this. I'll try it.
amazing to see the image in the demo scale down like that.

Ricksta

Set height to auto

bailey86's picture

Hi,

In the CSS for the images I've set the

height:auto;

and this then seems to override the height setting and allow for the aspect ratio to be correct.

Could use some advice on how to handle responsive images

ret5's picture

Hi all - Just started my first couple of sites using Omega and I like. A lot. But I am too having some difficulty figuring out how to get images to scale up and down automatically as the display size changes. I'm sure this is a CSS thing but not sure what the proper syntax is. Can someone give me an example of how this is implemented? Is it (or can it be) handled in the global.css file or do I need to establish the image size in each of the css files (narrow, normal, wide, etc.)? I tried that approach in the narrow.css file and all that happened is the image changed sizes when the display size was reduced however it didn't "transition" to the new size. Just big... or small... nothing in between.

I'm mainly concerned with the logo in the header at this stage but I'd like to address other img elements as well. oh... and while I'm at it, is there a way to use css to scale down the size of a views slideshow slider for use in Omega?

Thanks in advance for any advice...

different background-images

dhalbert's picture

For header images I just serve up images of different sizes in the CSS background-image specificationsin narrow, normal, and wide. For other images it's harder, and right now I just let the browser do the scaling. I set the width and do height:auto.

Responsive slideshow plugin

chaquea's picture

Try this nice responsive plugin for views slideshow

http://drupal.org/project/flexslider

Have you used that in

Circlefusion1's picture

Have you used that in production yet? It's a dev version. Is it stable enough?

I could use that in my current project.

That's nice, cheers.

drew reece's picture

That's nice, cheers.

For anyone wondering, I've

cellar door's picture

For anyone wondering, I've used flexslider in a couple sites now (not the module just added the js myself) and it's great. It now handles all my slideshow needs in Omega. Definitely the way I'd recommend going. Haven't tried the module yet, I'll have to test it out.

I haven't figured this out

drew reece's picture

I haven't figured this out entirely but I have seen an example that looks like it rescales the images within a views slideshow - http://nodeone.se/en I haven't managed to get time to unpick the css & js. It may be easier to find the developers & ask if they have used custom code for it.

I think it is a case of removing the image dimensions from the image & using image{ width:100%;} rule to fit them to the container.

FWIW here is the module I mentioned above, it removes the height from all images processed by Drupal (not sure about inline images) It also add's imgsizer.js from the unstoppable robot ninja 'fluid images' post.

http://dl.dropbox.com/u/59660/sizeless_images.zip
It's less than ideal for mobile because the device still downloads the large version.

Views slideshow is a bit

cellar door's picture

Views slideshow is a bit trickier. In the settings you'll find one for auto width and height, be sure both of these are disabled that way you can control the images programmatically.

As for images in general, I normally set the width and let the height auto scale along with it. One useful way to do it is rather than image{width:100%;} use this: image{max-width: 100%;} What this will do is let the image have it's original sizing until the containing div is smaller and will resize accordingly. Otherwise if it's not fluid or is a background image I'll just use CSS to resize the larger image according to my need, keeping in mind that if it is a background image I can reload it as necessary or use sprites wherever possible to reduce the amount of files needed.

The holy grail right now is trying to figure out how to serve the images based off the media queries. There's a few solutions that are floating around out there but nothing has come out as the stand alone solution.

I made a typo and forgot it

drew reece's picture

I made a typo and forgot it was max-width :)

I just saw there are a few console.logs() in flexisliders js file that should be commented out before putting into production…
http://drupal.org/node/1376826 otherwise it seems good, I just need to test more in IE to make sure the rendering looks good with the scaling.

Cellar Door are you using fluid images or any other JS to pretty up scaled images in IE ?
http://unstoppablerobotninja.com/entry/fluid-images/

Gotcha: well width 100% works

cellar door's picture

Gotcha: well width 100% works sometimes too but max-width is best of both worlds.

As for JS I'm not using anything right now but will probably be working out a solution based on node.js and lazyloading the images. Personally I feel that's the best way to get the right image for the right device. Right now I'm just making sure my images are optimized the best I can and am working on something more elegant from there.

Related to JS, I have been

jmolivas's picture

Related to JS, I have been testing this module Client-side adaptive image http://drupal.org/project/cs_adaptive_image kinda like the JS approach so you do not depend on Apache's .htaccess file

--
http://jmolivas.com/
@jmolivas

Thanks!

ret5's picture

Been meaning to update but got distracted. Just wanted to say thanks to everyone for the advice on getting these images to act in a responsive manner. Its working now! Thx

How?

harri00413's picture

How did you do it?
grtz
frank

Responsive & Adaptive Images, Slider & Video

jmolivas's picture

I achieved that functionality for a responsive Images, Slider & Video using a couple of modules. Demo in my blog on the following link: http://jmolivas.com

This is the list of the used modules:

Slider: Flex Slider
http://drupal.org/project/flexslider

images: Client-side adaptive image (in order to serve images based on device window size)
http://drupal.org/project/cs_adaptive_image

Videos: FitVids
http://drupal.org/project/fitvids

Responsive video demo: http://jmolivas.com/media/omega-3x-intro-responsive-design

--
http://jmolivas.com/
@jmolivas

Nice Modules

wiliam_steven's picture

Hi, Jmolivas,

I have been trying using the cs_adaptive_image and also the Flexslider and it work fantastic, but when it came with video (in this case im using mediaelement.js) for video player and also configuring fitVids module adding mediaelement-video class, it still not work, do you have any idea ?

Hi @wiliam_steven do you

jmolivas's picture

Hi @wiliam_steven do you have a link or screenshot ?, where I can see what is happening

--
http://jmolivas.com/
@jmolivas

Hi @wiliam_steven, I end up

jmolivas's picture

Hi @wiliam_steven,

I end up adding a few lines to the JS, it was related to the style injected by media module to the wrapping divs

  $('.media-youtube-outer-wrapper').removeAttr('style');
  $('.media-youtube-preview-wrapper').removeAttr('style');
  $('.media-vimeo-outer-wrapper').removeAttr('style');
  $('.media-vimeo-preview-wrapper').removeAttr('style');  

You can found updated JS file here, so you can review where to insert those lines or replace yours:

http://jmolivas.com/sites/all/modules/fitvids/jquery.fitvids.js

As you can read this workaround is forcing to remove styles from for youtube & vimeo wrapping only (not the best practice but it works).

--
http://jmolivas.com/
@jmolivas

What about inline images?

mrpauldriver's picture

For inline images I usually use CK Editor together with IMCE and find that using 100% width for images works well.

The disadvantages are that images sizes are not optimized for the viewport, potentially being slow to download on mobiles

Secondly, this approach is just way too complicated for a client.

Are there any simple methods for inline images that do not rely on field formatters?

@MrPaulDriver

Totally agree with you there

samwillc's picture

Totally agree with you there Paul, a client will have no idea how to add classes to inline images through the IMCE UI. I have seen it first hand, they chuck an image in, it's too big, doesn't float, looks rubbish and then they ask me "why does that look like that?". Umbraco cms used to have a little dropdown in the RTE where you could asign styles i.e. you insert an image and while it's selected, use the little dropdown so a client can select a human readable term like 'inline image'. That was very useful, not seen this yet in drupal. You can assign block formats if you want to add tags around things in the RTE but I've not seen a way to add a class through a dropdown.

The images being optimized have never been an issue for me so far, I mean you can limit how big the upoads are so they don't add camera photos at 4000px x 3000px or anything like that which only need to be displayed at 600px across.

I would definitely like to see a decent way to handle inline images.

Sam.

I'm going to put in a feature

mrpauldriver's picture

I'm going to put in a feature request with the clever chap at http://drupal.org/project/cs_adaptive_image

@MrPaulDriver

Maybe it's something that

samwillc's picture

Maybe it's something that could be integrated with ckeditor? Umbraco used TinyMCE and it was very successful on past projects.

Sam.

How do you handle

jmolivas's picture

How do you handle inline-image insertion in wysiwyg @paul & @samwillc ?
http://www.alligatorsneeze.com/image-uploads-using-wysiwyg-and-media-dru...

How about adding file-image formatting when inserting image see image below, in order to set Adaptive Image plus setting break points.
http://i.imgur.com/rR5Oi.png

--
http://jmolivas.com/
@jmolivas

Hi jmolivas, Not with the

samwillc's picture

Hi jmolivas,

Not with the media module that's for sure! It's a total disaster with Omega theme. Looks great, works bad. IMCE, looks bad, works great!

I use IMCE Wysiwyg API bridge ( http://drupal.org/project/imce_wysiwyg ), Wysiwyg ( http://drupal.org/project/wysiwyg ) and IMCE ( http://drupal.org/project/imce ).

These three combined allow for uploading, inserting from library, uploading and then inserting, anything you want. When you click on the insert image in ckeditor, a little popup appears with 'Image properties'. The bridge means that within that popup, there is a new link called 'browse server', from there you can access IMCE. It's a great combination but you have to manually assign classes to your inline images which is ok for me but not for clients.

Hope this helps.

Sam.

CK Editor, IMCE and CK Finder

mrpauldriver's picture

It's very flexible assuming one knows basic html and css.

But I am really looking for a stupid simple method for clients and this method is not the answer.

The links you posted look interesting, I'll take a look.

@MrPaulDriver

I'm with you Paul. Something

samwillc's picture

I'm with you Paul. Something like:

In RTE > press insert image button > popup (browse server or upload image) > select image > checkboxes for styles - an 'Inline image left', 'Inline image centre', 'Inline image right' > check required box > Insert > Job done

As I said, umbraco used to handle this with:

in RTE, insert image button > popup (browse server or upload image) > after insert the image is automatically already selected > go to dropdown with styes list > choose 'inline image' style or whatever you've called it and bingo, the required classes are added.

It was quite intuitive and I think this is an RTE issue, nothing to do with the image handling.

I think it's essential to take this away from clients. They should never need to add any code whatsoever even if it is just adding a css class.

Sam.

jmolivas - I've taken a look

mrpauldriver's picture

jmolivas - I've taken a look at the media module now and it is much improved since I last visited it.

Trouble is, I don't see how to apply the adaptive format to media module.

@MrPaulDriver

Is not already implemented,

jmolivas's picture

Is not already implemented, thats why I was mentioning "How about adding file-image formatting when inserting image see image below, in order to set Adaptive Image plus setting break points."

@paul totally agree with you media module is been improved a lot.

@samwillc do you have some screen-shots or mockups about this you mentioned to have a beter idea.

--
http://jmolivas.com/
@jmolivas

Hi jmolivas, I have made you

samwillc's picture

Hi jmolivas,

I have made you a screenshot, pardon the hilarious arrows! This is Umbraco v4 control panel but you'll get the point.

I made a dropbox account and chucked it in there, hopefully this will work:

http://db.tt/uY4WmjuI

Sam.

@samwillc you may want to

jmolivas's picture

@samwillc you may want to tray Media: Responsive http://drupal.org/project/media_responsive sorry for the delay in replying you back

--
http://jmolivas.com/
@jmolivas

I used resp_img

ravisagar's picture

I used resp_img on my site slashnode.in and it works great but as you guys are discussing I also want a responsive images in inline images that I insert via Insert Module

I just raised a feature request: http://drupal.org/node/1509088

I havent try resp_img but if

jmolivas's picture

I havent try resp_img but if you are adding inline images using Media Module ?, may want to tray Media: Responsive http://drupal.org/project/media_responsive

--
http://jmolivas.com/
@jmolivas

Hi jmolivas, What does this

samwillc's picture

Hi jmolivas,

What does this module do that can't be handled with a simple:

img {
max-width: 100%;
}

in the gobal.css?

I'm not sure how this would help insertion of inline images. One thing I have noticed, the media module does add a class 'media-image' to inserted inline images so they're pretty easy to style now.

Thanks.

Sam.

I tried this one, but it

DIRKMJK's picture

I tried this one, but it appears to distort the image? (Height is not adjusted)

The css will scale up the

drew reece's picture

The css will scale up the image but the built in image module will include the dimensions in the html image tag. If the size is in the html it overrides the css. You could try the media_responsive module or make your own custom module to remove the sizes from the output.

See chx's comment…
http://drupal.stackexchange.com/questions/14866/drupal-7-9-and-flexible-...

Thanks! In the page you link

DIRKMJK's picture

Thanks! In the page you link to there's also a suggestion to add height: auto to the css, which appears to work

This css add flexible

jmolivas's picture

This css add flexible capabilities to your images, I mean scales up/down as you resize your browser

--
http://jmolivas.com/
@jmolivas

create your image file types in Image module

bunthorne's picture

Don't forget that you can create your own file types (Configuration|Media|Image Styles) in the Media module. The options for file type include Crop, Scale, and Crop and Scale.

Ted Spencer
Addison Spencer Consulting LLC

cs-adaptive images + views or flex - how?

Diane Bryan's picture

I'm rather new at the drop, and I've got a nice slider going -- did it with Views, and used CSS to get the content text to serve as a hover-link in vertical tabs. (How come vertical tab side-by-sliders aren't all the rage?).

What I don't have is automatic image resizing. I have cs-adaptive images installed and enabled, and when I select that in the Views configuration, as my image style, some options pop up -- it wants me to name the image styles to apply at each break point.

Is that how this works? So it doesn't actually do it "automatically"... I have to actually dictate the media sizes at which to switch images, and name the image style for that break point?

Just making sure I'm on the same page with you all!
And thanks for this discussion! I think the light is starting to gleam thru the trees.

My way

bailey86's picture

This is for resizing the images.

  1. First of all work out the widest width you will need for your image - i.e. the width the image will be in the 'wide' browser size.

  2. Go to admin/config/media/image-styles and create a style which will scale to that width.

  3. For that field in your content type under Manage Display set the image field to use that style.

So - when you view that node - it will now display the image using a width which is suitable for the wide layout. We now need to set the CSS so that the image will display at narrower widths for the narrower browser sizes.

  1. OK - using Firebug or similar find the CSS selector which points directly at this image - something like:

div.field-name-field-main-image div div img {
}
  1. Now - in global.css set the CSS for this image to be suitable for the mobile view - e.g.

div.field-name-field-main-image div div img {
    width:334px;
    height:auto;
}

Setting the height to 'auto' means the aspect ratio is kept OK.

  1. Set the same block in the other CSS files; narrow, normal, and wide. This is because the style cascades up from mobile to the wider styles.

Use this block and choose the width as appropriate.

div.field-name-field-main-image div div img {
    width:334/520/700/880/etcpx;
    height:auto;
}

Voila - should all work fine.

(BTW - the example sizes I've used are for an image which is 12 columns wide in a 16 column wide layout).

Also, the reason I've set the image style is to cover for if a site editor uploads a bonkers large image size - at least the image which is being loaded has been resized down to the largest needed. This should help with loading speeds.

Omega Framework

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week