# Override image dimensions set by image style

I am trying to override the image dimensions set out by image style and can't seem to do that unless I select no image style for the field. I need that image style on another pages but I would like to override it only on the front page. The images the front page are from nodes loaded from simple view configuration. I tried theme_image_style to override the dimensions but it stops images from rendering on other pages. I tried theme_preprocess_node and even though the image['width'] and [height] were changed it still loaded the image style dimension. Would really appreciate some help thank you.

You could alter the width and height properties of your image(s) using CSS, it depends on the (base) theme you use in which file these CSS rules should be entered. However, the image produced by the image style is still used (so, this might not be quite mobile friendly).

Another option is to use the Image Style Selector (ISS) module, which provides an extra field on your node edit page that you can use to select an extra image style (to apply on the image on for instance your front page). When displaying the node on the front page you can hide the original image field and display the ISS field (the result is that your image will be shown using the style selected in the ISS field).

• I wanted to achieve this without using CSS. and also without any additional modules. – Sanjok Gurung Jan 9 '17 at 13:04

The looked around images styles and this works for me so far, although it is not working on a custom image style I created, however it could be I have some configuration issues so I believe it should be work.

I created a renderable array on the node view template file.

//Loading the image field from the node object
$image_field = field_get_items('node',$node,'field_image');
$image_item = array( 'style_name' => 'my_medium_style', 'path' =>$image_field[0]['uri'],
'width' => '',
'height' => '',
'alt' => $image_field[0]['alt'], // optional 'title' =>$image_field[0]['title'], // optional
);
print theme('image_style',\$image_item);


Although I am pretty sure there are better solutions, but for now I would like to mark this as the closest solution.