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...
Comments
Comment #1
alexverb commentedAdded a patch with a small helper function instead of drupal_attributes().
Comment #2
quicksketchThanks @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.
Comment #3
marktheshark commentedI 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.
Several backslashes and
"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?
Comment #4
marktheshark commentedTried 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="\\"dw\\"" title="\\"eew\\"" width="\\"268\\"" height="\\"170\\"" class="\\"image-large\\"" /></p><p>gdfgdf</p><p> </p><p><img src="\\"/sites/default/files/styles/large/public/images/news/body/score-big.jpg\"" alt="\"fd\"" title="\"sd\"" width="\"400\"" height="\"300\"" class="\"image-large\"" /></p><p> </p><p>dfgdf</p><p> </p><p><img src="\"/sites/default/files/styles/large/public/images/news/body/mytilinionmap.jpg"" alt="ewr" title="ew" width="212" height="147" class="image-large" /></p>Comment #5
marktheshark commentedI guess my problem is probably this.
Edit: No it isn't after all, magic quotes is disabled on my server.