Hi,

After some time of debugging I'm not able to find out other way than make chages in theme_image function so I'm reporting this issue.

I'm using media module and it's functionality to add an image directly in wysiwig editor (Full HTML) of body text.
I added image in this way and I try to change it's size by taking corner of the image by mouse. The image is then nicely resized. After saving the change the image markup is saved to DB. But when I want to see it in normal display mode on my webpage then the image preserves in its original size.

I've found that markup is correctly parsed and passed to theme_image function. The info about new size (the size that I've changed by mouse) is passed in attributes array (nested array of $variables). And the theem_image function works so that all information about size is replaced by the original size of image.

For my purpose I rewrote the method theme_image like this:

function theme_image($variables) {
  $attributes = $variables['attributes'];
  $attributes['src'] = file_create_url($variables['path']);
  foreach (array('width', 'height', 'alt', 'title') as $key) {
    // adding check of existence $key in attributes array
    if (empty($attributes[$key]) && isset($variables[$key])) {
      $attributes[$key] = $variables[$key];
    }
  }
  return '<img' . drupal_attributes($attributes) . ' />';
}

I don't know the whole context of theme_image callings so in case that my issues is not real, please be so kind and close it. Thanks.

Comments

marcingy’s picture

Project: Drupal core » D7 Media
Version: 7.12 » 7.x-2.x-dev
Component: theme system » Code

Isn't the issue with the media module

Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

I'm not quite sure I understand the actual problem/bug here. This could use detailed steps on how to reproduce.

chalda’s picture

Ok, here it is.

I use media modules in WYSIWYG editor TinyMCE.
1) I create new Basic Page and I want to add some image into the body text area.
2) I use the "Add media" button. I find image on my disk, let the drupal to upload it and I define e.g. Original format of the image to be used.
3) Now the image is pasted to the text area and I can see that the image is a little larger than I though. So I change the size of image directly in the TinyMCE. I take the corner of the image and I change the size.
4) I save the Basic Page
5) The image is shown on the resulting page but its size is that one which the format Original defines. But I want the image to have the size which I have changed manually in the text editor.

The problem is that (at least it seems to me so) the media module does not reflect the change which was done by changing the size of the image directly in the text editor. I was a little hanging out in the code. But I've finished at the fact that the theme.inc gets information about the size of the image in $variables['attributes']. It's that size which I defined manually in the wysiwyg text editor. But then the code takes the size which was defined by "Original format".

Is my explanation better now?

Dave Reid’s picture

I don't believe that our WYSIWYG integration supports TinyMCE's resizing/tweaking of images.

Dave Reid’s picture

Title: Media module markup is not correctly handled in theme_image function » Disable TinyMCE image resizing on Media images in WYSIWYG
Component: Code » WYSIWYG integration
Status: Postponed (maintainer needs more info) » Active

Looks like we need to be having the WYSIWYG add mce_noresize="1" to images in the wysiwyg.
http://code.google.com/p/tinymce-plugin-advimagescale/wiki/Usage#Prevent...(on_some_or_all_images)

yuriy.babenko’s picture

The mce_noreize option referenced above doesn't seem to have any effect for me. Tried running it through the settings_alter hook below, adding it as an attribute to the <img> tag, etc.

I've disabled TinyMCE's image resizing with this code in a custom module:

/**
 * Implements hook_wysiwyg_editor_settings_alter().
 */
function mymodule_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'tinymce') {
    $settings['object_resizing'] = FALSE;
  }
}
marcvangend’s picture

The code in #6 is a perfect quick fix. Thanks.

gmclelland’s picture

#6 worked for me. Thank you

Chris Matthews’s picture

Component: WYSIWYG integration » Code
Status: Active » Closed (outdated)

Closing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team