Is it possible to use image_style_url with an adaptive image style and, if so, how? Here's the code i'm using:

<img src="<?php print image_style_url('my_adaptive_style', 'public://path/to/image.jpg'); ?>" />

which is producing this markup:

<img src="http://example.com/sites/example.com/files/styles/my_adaptive_style/public/path/to/image.jpg" />

Notice it's not creating the necessary break point directory (1024, 960, whatever). It should look something like:

<img src="http://example.com/sites/example.com/files/styles/my_adaptive_style/public/path/to/1024/image.jpg" />

Comments

I have the same issue. Could some one please help?

How can we use adaptive image module to display different size of images on on desktop, tablet and on iphone?

I have the same issue using image_style

<?php
print theme('image_style', array('style_name' => 'full_page_image', 'path' => $content['field_image']['#items'][0]['uri'], 'alt' => $content['field_image']['#items'][0]['alt']));
?>

This pushes out /sites/default/files/styles/full_page_image/adaptive-image/public/field/image/Williams%20Closing%20120614%20010.JPG

I was having this same issue and ended up changing my template so that it printed out the image URL via views (using the image style) I had set up.

#1
What do you mean by different sizes? The breakpoints should be set unless the imagestyle was overwritten which means normally the sizes should change with different resolutions (not depending on window-size).

Basically you are overriding the "style_name", this causes the detection in the module to fail (adaptive_image.module, line 172).

Looking at the code in the dev version it seems like the adaptive styling will only apply for output that's gone through theme('image', $vars)? Can anyone verify this? I say this as it looks like all the special scaling logic is initiated through adaptive_image_preprocess_image(). Perhaps this would explain why simply calling image_style_url() (without later passing the returned url through theme('image')) will not work?

I'm maintaining a module that needs to extract styled image URLs for output in XML (currently I just use image_style_url() for this), and therefore does not do any theming on the image output. I'm assuming that because I'm not theming my output there is no way for my module to take advantage of adaptive_image?

I'm having this problem also. Is there a way to get this working when the image is printed using image_style_url()??

I just ran into the same issue myself and took a deeper look.

Essentially, after calling image_style_url you need to post-process the url in the same way that adaptive_image_preprocess_image does. image_style_url grants the token to create the image, but to get it generated and used, you need to modify the url to use the proper resolution using the adaptive_image helper functions, or to it's generator function so that adaptive_image can create the image.

The following is ugly, but works. There should really be a function adaptive_image_style_url($style, $path){} in the module that implements this.

<?php
$style_name
='my_style';
$uri = 'public://myimage.png';
$path=image_style_url($style_name, $uri);
global
$base_url;
$style = image_style_load($style_name);
if (!
$style || !adaptive_image_contains_effect($style)){
   
$url = $path//adaptive image isn't set for this style
}
$settings = adaptive_image_effect_settings($style);
$resolutions = explode(',', $settings['resolutions']);
$resolution = adaptive_image_resolution($resolutions);
if (!
strpos($path, '/system/') && is_numeric($resolution)) {
   
$path_parts = pathinfo($path);
   
$derivative_uri = $path_parts['dirname'] . '/' . $resolution . '/' . $path_parts['basename'];
}
if (isset(
$derivative_uri) && file_exists(str_replace($base_url, '.', $path_parts['dirname'] . '/' . $resolution . '/' . array_shift(explode('?', $path_part['basename']))))) {
   
$url $derivative_uri;
} else {
   
$url str_replace("styles/$style_name", "styles/{$style_name}/adaptive-image", $path);
}
$new_path = $url;
?>