i have image upload field in my theme-settings.php

$form['fsos_settings']['intro']['hero']['heroImage'] = array(
    '#type' => 'managed_file',
    '#upload_validators' => array(
    'file_validate_extensions' => array(0 => 'png jpg jpeg gif'),
    '#upload_location' => 'public://image/home/',
    '#description' => t("Upload an image."),
    '#default_value' => theme_get_setting('heroImage'),

I can print this in my page.tpl.php using the following code

<img src="<?php print file_create_url(file_load(theme_get_setting('heroImage'))->uri); ?>"/>

But i want to use Image Styles (heroimage) for the size. How can i get the image styles URL instead of the original URL


2 Answers 2


Heres an example using theme_image_style()

$mypath = (file_load(theme_get_setting('heroImage'))->uri);
print theme_image_style(
    'style_name' => 'heroimage',
    'path' => $mypath,
    'attributes' => array(
    'class' => 'YOUR_IMAGE_CLASS'
    'width' => NULL,
    'height' => NULL,

I'll be honest, I cant remember why I set height and width to NULL, off the top of my head it helped fix some bug! Hope it helps!


You can use this:

<img src="<?php print image_style_url('heroimage',$image_link_uri); ?>" />

$image_link_uri would be the URI link of your image

That should work !

  • could u give me example for the image style url
    – user81244
    Commented Jun 20, 2016 at 18:08
  • @user81244 See this doc api.drupal.org/api/drupal/modules!image!image.module/function/…
    – Gulok
    Commented Jun 20, 2016 at 23:08
  • @user81244 I just did it with that line, applying yout image style into that line, just replace the variable $image_link_uri with your uri file and you'll be done
    – DarkteK
    Commented Jun 21, 2016 at 4:07

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.