With Drupal 6, if I used imagecache and insert, I could insert images using preset small-image (scale to 200px), medium-image (scale to 350px), etc. Then, if I wished to make small-image 203px because that fits better with my theme, all the images set to small-image would resize. Perfect.

In Drupal 7, when I click on insert using preset small_image, the image gets full attributes - such as alt, title, width 200px, height 175px, etc.

BUT, if I decide that I want small images to be 180px (for example), when I change the preset to scale to 180px, the inserted images stay at the original size of 200px X 175px (for example) and become pixelated (especially if I increase the size) and I have to delete the dimensions part of the <img> if I want them all to update correctly right across the site.

So, is it possible for insert to NOT input the preset sizes when inserting images, so all images site-wide will resize when the preset is changed?

Thanks a lot.

Comments

TelFiRE’s picture

This is if I'm not mistaken an issue of core. I am with you, I totally despise this new trend. While web browsing speeds get faster, we worry ourselves sick about smaller and smaller differences in speeds. In order to have a modern website you cannot have these attributes hard coded!

markconroy’s picture

Hi TelFiRE,

I think you are correct. How disappointing:
http://drupal.org/node/1448124

quicksketch’s picture

Category: feature » support
Status: Active » Fixed

So, is it possible for insert to NOT input the preset sizes when inserting images, so all images site-wide will resize when the preset is changed?

You can override the image-insert-image.tpl.php and insert-image.tpl.php files and remove the height/width attributes if you so desire.

markconroy’s picture

Hi Quicksketch,

Does that just mean copying the image-insert-image.tpl.php file to my theme folder and editing this line:
<img src="<?php print $url ?>" <?php if ($width && $height): ?>width="<?php print $width; ?>" height="<?php print $height; ?>" <?php endif; ?>alt="__alt__" title="__title__" class="image-<?php print $style_name ?><?php print $class ? ' ' . $class : '' ?>" />

to this
<img src="<?php print $url ?>" <?php endif; ?>alt="__alt__" title="__title__" class="image-<?php print $style_name ?><?php print $class ? ' ' . $class : '' ?>" />

And copying insert-image.tpl.php to my theme folder and editing this line:
<img src="<?php print $url ?>" width="<?php print $width ?>" height="<?php print $height ?>" alt="__alt__" title="__title__" <?php print $class ? 'class="' . $class . '" ' : '' ?>/>

to this
<img src="<?php print $url ?>" alt="__alt__" title="__title__" <?php print $class ? 'class="' . $class . '" ' : '' ?>/>

If so, why is there always such a simple solution when using Drupal? Thanks sooo much.

quicksketch’s picture

Yep you got it Mark. And don't forget to flush the Drupal cache to get Drupal to pick up the new template file copies.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Does this template file approach still work with 7.x-1.3? It seems to have no effect for me, even after clearing the cache.

efpapado’s picture

Version: 7.x-1.2 » 7.x-1.3
Issue summary: View changes
Status: Closed (fixed) » Active

Solution #4 doesn't work in 7.x-1.3
Any ideas?

jesss’s picture

If you're using an administration theme, simply overriding the tpl.php won't work -- your admin theme can't see the templates in your front-end theme.

What you need to do instead is create a custom module, put your template overrides there, and use hook_theme_registry_alter() to tell the theme system where to find them.

/**
 * Implements hook_theme_registry_alter().
 */
function MY_MODULE_theme_registry_alter(&$theme_registry) {
   $path = drupal_get_path('module', 'MY_MODULE');
  
  // override the insert module's templates with our own custom ones
  if (module_exists('insert') && isset($theme_registry['insert_image']['template'])) {
    $theme_registry['insert_image']['template'] = $path . '/templates/insert-image';
  }
}
Snater’s picture

Status: Active » Closed (duplicate)

An alternative to creating a custom module is to create a subtheme of the admin theme, described at https://www.drupal.org/node/2203477