theme_image_style() doesn't output what is expected I have a module that doesn't seems to work correctly, so I dived into its code, and there is something that I don't understand:

The module does something like this: (I replaced the 'path' key with an hardcoded value to show the problem)

$params = array(
    'style_name' =&gt; $presetname,
    //'path' =&gt; $image_url,
    'path' =&gt; "public://images/image.jpg",
    'attributes' =&gt; $attributes,
    );


Then $param is sent to the theme_image_style() hook

$img = theme('image_style', $params);


The problem is that if i dump the output of theme_image_style():

dpm( $img);


then i get

&lt;img typeof="foaf:Image" src="http://mysite.local/sites/default/files/styles//public/images/image.jpg?itok=qZxUAGIS" alt="" data-thmr="thmr_99 thmr_100" /&gt;


In admin/config/media/file-system, my public path is set as: sites/default/files

I should have:

src="http://mysite.local/sites/default/files/images/image.jpg


instead of:

src="http://mysite.local/sites/default/files/styles//public/images/image.jpg


Why does the theme function add 'styles//public' and where could I remove this?

Thanx in advance for your help
Drupal 7 provide Image style functionality which allow administrator to set predefined size and can apply image style to any image in site.


  Using image styles you can scale, crop, resize, rotate and desaturate
  images without affecting the original image. By default three sizes
  are defined: 'thumbnail,' 'medium', and 'large'. The thumbnail style,
  for example, is shown with the teaser for image posts and when
  browsing image galleries.


In your code, you have defined $img = theme('image_style', $params); which mean that you are applying image style to your image. 

When we apply image style to any image, it will create a new image in styles/[stylename]/public directory and does not affect the original image source.

There is no stylename in your http://mysite.local/sites/default/files/styles//public/images/image.jpg url after style part of url, so I guess $presetname is not properly defined in your code.

You can try below exammple:

$params = array(
    'style_name' =&gt; 'thumbnail',
    //'path' =&gt; $image_url,
    'path' =&gt; "public://images/image.jpg",
    'attributes' =&gt; $attributes,
    );
$img = theme('image_style', $params);