Posted by citronica on February 10, 2009 at 2:42am
| Project: | Image Resize Filter |
| Version: | 6.x-1.0 |
| Component: | Documentation |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
When you add the Image Resize Filter to an input format, you must put the Image Resize Filter before the HTML Filter.
This is at Admin > Site configuration > Input Formats > [your format] > Rearrange.
Comments
#1
The plot thickens... if I have the HTML Filter enabled at all, when I edit a node with a previously resized image, FCKeditor shows the original size image. I think this is because the HTML Filter stripped out the "style" attributes in the IMG tag. See http://drupal.org/node/75668 for more on this.
I'd rather not disable the HTML Filter altogether, so if there's a workaround I'll post it here.
Cheers,
Andrea
ETA: So far it seems to work OK with HTML Purifier (http://drupal.org/project/htmlpurifier) rather than the core HTML Filter. I'm using the basic (not advanced) filter with no special settings. Oddly enough, I'm running it first, before the other filters.
#2
So if you're using the core Filter HTML filter and FCKeditor (which uses styles to set height and width by default), setting the HTML Filter to run after Image Resize Filter doesn't work? Because Image Resize Filter adjusts the height and width on the image itself, it should be able to work around the fact that the style property is then stripped out later.
Another option is simply to configure FCKeditor so that it uses height and width tags instead of adding style information.
---
Okay I did a bit of research on FCKeditor (I don't use it personally). Turns out FCKeditor doesn't even insert height and width tags at all for images if they've been resized. This is dumb. :P
Sounds like the only way we could make the two work together (other than disabling HTML Filtering entirely) would be to improve the regex in Image Resize Filter to insert height and width tags if they are currently missing. I couldn't find any configuration options in FCKeditor to make it use normal height and width tags.
#3
When I do it with HTML purifier, it does not create height and width tags -- it simply adds height and width CSS attributes:
style="width:295px;height:155px;"
Quicksketch, let me know if you need a login on my site to play with this, or if there's any testing you'd like me to do.
Cheers,
Andrea
#4
Right, HTML Purifier basically allows you to continue using style attributes. The HTML Filter will strip out all styles, including the height and width tags.
#5
I seem to be a few steps behind you... sorry! I guess that's why your book is on my desk and not the other way around ;-)
Yes, FCKeditor never bothers to add height and width tags at all. I changed my input format so the only filter is Image Resize Filter, and there still aren't any height/width tags.
It would be great if you could make that regex tweak you described above!
#6
Okay, not exactly a "tweak", but this patch should fix the problems. We still need to have the Image Resize Filter run before the Filtered HTML filter, since if the style property is stripped out before Image Resize Filter gets it, it doesn't know what size the image should be.
Since this patch is crazy (I hadn't thought about style-only implementations before this), I went ahead and committed it. Could you try and use the latest copy from CVS and see if it fixes your problem? Here's a direct link so you can copy/paste the latest code into your copy.
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/image_resiz...
#7
And... a second patch. This one actually fixes the title of this issue, which is that the order of the filters might make a difference in how Image Resize Filter works. This patch makes it so that Image Resize Filter takes catalog of all the images *first* before other filters are run, then does the replacement in whatever the filter order is.
Again, I committed it directly, so you can try it out by using this latest code, or applying the attached patch.
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/image_resiz...
#8
Well, it does add the height and width tags, and it works equally well if I run Image Resize Filter before or after the HTML Filter.
But... when I click on the node edit button and return to the edit screen with FCKeditor, the image is back at its original size.
Works fine with HTML Purifier, though, in any order. The difference seems to be that HTML Filter strips out the style="width:417px;height:312px;" attribute, which HTML Purifier leaves intact.
#9
Hmm, that sounds like some other kind of problem. This module doesn't affect the contents of the edit screen at all. The actual modification only occurs on output, so there's no way that this could be affecting the markup you've entered while editing the node.
#10
If okay, I'm going to mark this as fixed, since we've fixed the filter ordering issue. Now it's just FCKeditor misbehaving somehow.
#11
#12
Updating title for posterity
#13
Hmm.. I wrote #351991: Detect css styles, in addition to height/width attributes to support FCKeditor. The HTML filter removes the height/width style tags, the fix is to use "Full HTML" or a different HTML filter.
#14
rmrfstar, after this patch, FCKeditor works even with Filtered HTML, as it will detect style height/width before they are stipped out, then add height and width tags if needed. So now it works regardless of the HTML filter.
#15
Automatically closed -- issue fixed for 2 weeks with no activity.