0

In my content type, I've got an image uploader. That image then gets processed by an Image Style that scales the image. I want to produce multiple scaled sizes of that image though. So essentially, I need to assign multiple Image Styles to that one image upload. In the UI, I can only assign one. This is Drupal 7, by the way.

So, for example: I start by uploading an 800x600 image and I've applied an Image Style to output it at 400x300. Now I want to apply another Image Style to get a 200x150 version. And so on...

Surely, I'm missing something here! Seems like a straightforward request. Thanks in advance!

5
  • 1
    What are you trying to do? Image derivatives are created on-demand when they are requested, so it possible to do anything you want, but we need some more information on what that is.
    – mpdonadio
    Commented Mar 4, 2013 at 21:08
  • For example: I start by uploading an 800x600 image and I've applied an Image Style to output it at 400x300. Now I want to apply another Image Style to get a 200x150 version. (appended to question) But I'm intrigued by your comment of "Image derivatives are created on-demand when they are requested". How do I request them? Specifically, how in a content template?
    – Sam
    Commented Mar 4, 2013 at 21:11
  • Hang on... I might be looking for something like this function: image_style_url($style_name, $path) api.drupal.org/api/drupal/modules!image!image.module/function/…
    – Sam
    Commented Mar 4, 2013 at 21:24
  • Confirmed! @MPD Thanks! I Googled for "drupal request image derivative" and found the answer immediately.
    – Sam
    Commented Mar 4, 2013 at 21:34
  • Hi, Sam. Can you please write more details about using the image_style_url() function? Are you using any specific hook? A snippet of your code will be very useful. Commented Jul 6, 2014 at 18:40

2 Answers 2

2

This is the function that I was looking for:

image_style_url($style_name, $path)

More info here.

(Should have done a little more digging via Google before I asked!)

1
drush image-flush

is a very useful command to regenerate all images associated to any defined Image Style. Use

drush image-flush -h

for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.