The Problem: A user is using TinyMCE with img_assist. They insert an image, setting its alignment to 'left'. They then add a link around the img_assist tag. They submit the page, and the linked image looks fine, and works everywhere except IE (tested on IE7). In IE the link doesn't work. The html that's failing looks like this:
<a href='some-link'><span class="inline left"><img class="image img_assist_custom" width="123" height="456" title="" alt="" src="http://example.com/image.jpg"/></span></a>
At the end of img_assist.css we have these rules:
span.left {
float: left;
margin: 5px 5px 5px 0px;
}
span.right {
float: right;
margin: 5px 0px 5px 5px;
}
The problem with this is that we're trying to apply 'float: left', and 'float: right' to spans, which are inline elements, but float only makes sense for block elements. This normally doesn't matter, but it seems to be tripping IE up. My fix is to change the above css to:
span.left img {
float: left;
margin: 5px 5px 5px 0px;
}
span.right img {
float: right;
margin: 5px 0px 5px 5px;
}
This applies the float rules to the img tags, which are block elements, and makes the links work in IE.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | img_assist_24.patch | 3.96 KB | sun |
| #7 | img_assist_23.patch | 3.47 KB | sun |
| #1 | img_assist.css_.align_.patch | 704 bytes | sun |
Comments
Comment #1
sunAgreed.
Comment #2
sunComment #3
zoo33 commentedYes, but what about captions:
Wouldn't this patch mess up how images and captions are aligned? I didn't test it (sorry) but it seems wrong. How about changing the surrounding span to a div and floating that instead?
Comment #4
sunI think you are right, although I'm not 100% sure, too. However, DIVs are not an option because they span over all available width unless the width is explicitly defined via CSS.
We could try to turn this into
Comment #5
sunEeerrm... where's my head?!
Seems like we need something completely different to solve this.
Comment #6
TobiasH commentedWhy not use
?
Comment #7
sunLet's stick to DIV containers, including the caption.
Attached patch also renames those ambigious CSS alignment classes to
inline-[align].Comment #8
TobiasH commentedI've tested your patch with Garland and it seems that it solves the bug.
A problem I see with that inline classes. Why do we give class="inline" to a float-element. I think class="inline" should be given to none-aligned images. The css code for inline could be:
Styling of images can take over another class instead of inline.
Comment #9
sunI agree that 'inline' is somewhat misleading. However, it's valuable to have a common class name for all inline images (so all inline images can be styled equivalent easily) and AFAIK the class name is not ambigious (in Garland theme at least).
Since I'm also the maintainer of Inline module and there is already a draft to form an Inline API (a future release of Image Assist could be based on), I would not alter this class name now, since it would be renamed back to 'inline' when Inline API will be released and integrated someday.
Anyway, your point for styling of non-aligned images is not yet solved. We might implement
However, what happens to captions for non-aligned images? How have those captions been styled in previous versions?
Comment #10
zoo33 commentedI don't suppose we could have solved this with:
That is, stick with spans but add
display: block. That way we wouldn't need the style attribute on the div. Don't know if it would work in IE though.Anyway, I'm OK with the last patch as it is. I don't think the naming confusion is such a big deal. "Inline" refers to "inline images" in this case – and I don't think it's really desirable to map class names to the style it's using anyway. After all, you're supposed to name classes so that they make sense WRT the page structure: like "content", "search" etc., not "big", "wide" etc.
Comment #11
sunReverting to SPANs, but always including alignment class and removing the width at all.
If an image is centered, the width for the caption is not limited. Additionally, the caption is centered, too. However, we could add
text-align: left;to the caption. I'd like to hear your votes on that.Removing the width from captions at all is not possible, unless we find a nifty CSS trick to limit the caption's width to the width of an left or right aligned image.
OT: The 'link to url' option is not working, $attributes['url'] isn't set. I'll file a separate issue for that.
Comment #12
zoo33 commentedSo... style attributes are still necessary for captions. Hm. Maybe divs aren't so bad after all. If we used divs with the width set in a style attribute then maybe the captions wouldn't need to specify it. (That 2 pixel subtraction of caption widths could be done with padding instead.)
Spans or divs... I don't know, either way is fine with me.
Comment #13
TobiasH commentedThe idea with the DIVs wasn't really good. Sorry. If you put an image between P-tags you get errors trough validating your site. I've tested the patch in #11. There seem to be no disadvantages after changing.
Comment #14
sunCommitted #11, thanks!
Comment #15
(not verified) commentedComment #16
tahiticlic commentedHi,
I've just had the same problem with 3-x.dev version. I had to change the styles in img_assist.css to :
Comment #17
borsna commentedI had the same problem as #16,
changing "span.inline-left{" to "span.inline-left img{" worked great.
Comment #18
sunReverting to fixed, as I believe that the last follow-ups need a separate discussion (which might exist already, so please search the active issues before creating a new one, thanks).