Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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" />
share|improve this question
up vote 3 down vote accepted

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; ?>" />
share|improve this answer
thanks, overriding with CSS was the simplest way, though maybe not the best – Lambrusco.Newbie Dec 26 '13 at 12:44
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.

share|improve this answer

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.