The following theming function encodes the attributes through drupal_attributes().

/**
 * Generate a themed image tag based on an image array.
 *
 * @param $image
 *   An array containing image information and properties.
 * @param $settings
 *   Settings for the input filter.
 */
function theme_image_resize_filter_image($variables) {
  $image = $variables['image'];
  $settings = $variables['settings'];

  $output = '<img' . drupal_attributes($image['attributes']) . ' />';
  if ($image['link']) {
    $output = '<a'. drupal_attributes($image['link']['attributes']) . '>' . $output . '</a>';
  }
  return $output;
}

But what if I add an image attribute through my WYSIWYG, Ckeditor and IMCE setup. It seems to allready insert encoded characters. So if I place this filter on top of this I get double encoding of the attribute values.

My thinking is we should not be using encoding to build our image attributes since something else is allready handling it. So we should just rebuild the array as attributes without encoding...

If I'm right about this I would be glad to supply a patch...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexverb’s picture

Status: Active » Needs review
FileSize
1.78 KB

Added a patch with a small helper function instead of drupal_attributes().

quicksketch’s picture

Thanks @alexverb, I think you're right on all counts here. I'll give this a review next time I'm working on Image Resize Filter.

marktheshark’s picture

I have an issue where Insert + Image resize filter appears great in the WYSIWYG editor and upon saving it becomes a partially HTML-escaped mess, e.g.

<p>cxdffd</p><p><img src="/sites/default/files/styles/large/public/images/news/body/dancelife.png\" alt="\&quot;Test\&quot;" title="\&quot;This" width="\&quot;354\&quot;" height="\&quot;98\&quot;" class="\&quot;image-large\&quot;" /></p><p>&nbsp;</p><p>fdfdfd</p><p>&nbsp;</p><p><img src="\&quot;/sites/default/files/styles/large/public/images/news/body/thegshop.jpg&quot;" alt="" width="164" height="60" class="image-large" /></p>

Several backslashes and &quot; symbols don't belong there...

I have "link to original" enabled and the filter is set after the BBCode filter and before everything else.

Is this the same issue?

marktheshark’s picture

Tried the patch. Didn't solve my problem. Still get garbled output:

<p>gdfgd</p><p><img src="/sites/default/files/styles/large/public/images/news/body/logo_transparent.png\\" alt="\\&quot;dw\\&quot;" title="\\&quot;eew\\&quot;" width="\\&quot;268\\&quot;" height="\\&quot;170\\&quot;" class="\\&quot;image-large\\&quot;" /></p><p>gdfgdf</p><p>&nbsp;</p><p><img src="\\&quot;/sites/default/files/styles/large/public/images/news/body/score-big.jpg\&quot;" alt="\&quot;fd\&quot;" title="\&quot;sd\&quot;" width="\&quot;400\&quot;" height="\&quot;300\&quot;" class="\&quot;image-large\&quot;" /></p><p>&nbsp;</p><p>dfgdf</p><p>&nbsp;</p><p><img src="\&quot;/sites/default/files/styles/large/public/images/news/body/mytilinionmap.jpg&quot;" alt="ewr" title="ew" width="212" height="147" class="image-large" /></p>

marktheshark’s picture

I guess my problem is probably this.

Edit: No it isn't after all, magic quotes is disabled on my server.