I want to remove width and height properties from img tags in certain content type

Currently it show's like this

<img src="http://somesite.com/dostavka-slider-ng.jpg?itok=KDymQiug" width="938" height="300" alt="blablabla" title="blablabla" />

but I want

<img src="http://somesite.com/dostavka-slider-ng.jpg?itok=KDymQiug" alt="blablabla" title="blablabla" />
  • i'm having same issue with my image in view, i didn't find any option to remove in template file , currentlty image.html.twig is getting applied. You have any idea?
    – rks
    Commented Nov 12, 2018 at 4:46

3 Answers 3


Here are some ways how to achieve this:

  • Override it with CSS !important (something like width: auto !important;);
  • Override field.tpl.php
  • Copy node.tpl.php to the theme folder and rename it, like node--MY_CONTENT_TYPE.tpl.php.


/* node--MY-CONTENT-TYPE.tpl.php */
$img_url = image_style_url('large', $node->field_image['und'][0]['uri'];
<img src="<?php print $img_url; ?>" />
  • thanks, overriding with CSS was the simplest way, though maybe not the best Commented Dec 26, 2013 at 12:44
  • If you do anything like the last suggestion you lose alt and title tags and cannot make the site accessible.
    – acrosman
    Commented Dec 8, 2017 at 17:25
function mytheme_preprocess_image(&$variables) {
  foreach (array('width', 'height') as $key) {

copy this on template.php (replace "mytheme" to ur theme name) but you need to control over this because it will remove dimensions of all images in your theme.

  • Yes - the only way I can see to filter this is by file name which means it isn't very useful.
    – Interlated
    Commented Sep 30, 2017 at 0:50

Sorry, i can't use comment function -> need min. 50 points :-/

Do you want to display images in image field, you can use field template function. You can create .tpl file with the field name in you theme folder and edit the code.

The templates that are possible to override include:

  • field.tpl.php
  • field--field-type.tpl.php
  • field--field-name.tpl.php
  • field--content-type.tpl.php
  • field--field-name--content-type.tpl.php

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.