For compatibility with http://drupal.org/project/fckeditor and http://drupal.org/project/imagebrowser
I have modified image_caption.js to include the following lines - this transfers the 'class' attribute from the image to the containing div as in the case of imagebrowser, the alignment is done by it altering the 'class' rather than the 'align' attribute.
var imgclass = $(this).attr('class');
$(this).removeClass(imgclass);
$(this).wrap("
");
Hope this is of help to someone - not sure how compatible it is with other editors & image inserters.
Peter
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | image_caption_css_float.diff | 1.64 KB | fabianx |
| #6 | image_caption_css_float.diff | 2.03 KB | fabianx |
Comments
Comment #1
anrikun commentedI've modified it this way, so that the CSS 'float' property of the image is transfered to the div:
Comment #2
jannalexx commentedthis one works with CKeditor module inserted images, otherwise captions are overlaying content, (as far as I can guess it has to do with height css property). Some css tweaks may be needed if style properties used in ckeditor.
Comment #3
panhead490 commentedCan you help me understand where you are making this change? And then is there a way to translate this to the input filter shipped with image_caption so there's a JS free way of doing this?
Comment #4
panhead490 commentedDefinitely can't read since you clearly stated: I have modified image_caption.js
The second question if there's a way to do this sans JS/through the input filter still stands.
Thanks for your help.
Comment #5
fabianx commentedImage Caption JS code for 2.5:
Patch:
Comment #6
fabianx commentedHi,
I think this can be safely commited and will enable Image Caption to work with more Editors, so I add a real patch and change status to "needs review".
Best Wishes,
Fabian (LionsAd)
Comment #7
davidwhthomas commentedThanks, I will commit suitable patches that have been reviewed and tested by the community.
DT
Comment #8
essbee commentedFurther to help support this should the container take its width from the style rather than form the image width= property.
This would allow for scenarios where the img tag does not use width property but rather uses style="width: 100px"
Line 66 would need changing to search for width: rather than width=
IE
//replaced preg_match ('/width=\"(.+?)\"/i', $imgText, $matches);
preg_match('/width: (.+?);/i', $imgText, $matches);
I guess the ideal scenario would be to assess both so that either was supported.
Sam
Comment #9
ngstigator commentedsubscribing
Comment #10
vood002 commentedI tested updated JS in #5 and it worked better for me.
I unset the style & align though rather than setting them to "" as seen in #1
Comment #11
fabianx commentedHere is a short update code and patch:
Code:
Things new:
* use removeAttr instead of setting to "".
* allow usage of alt tag as caption.
* use inline for the container instead of block to fix IE issue.
New patch attached. Please test.
Best Wishes,
Fabian (LionsAd)
Comment #12
bryancasler commentedThis needs to get comitted
Comment #13
DrDeezee commentedAccidentally posted in the wrong thread, please disregard / delete this.
Comment #14
topdillon commentedDoesn't seem to work for me. Only works for image that is not floated left or right and that is width of container --i.e. for image of 200px in content that is 600px, caption is 600px wide.
Comment #15
fabianx commented@#14: Okay, need to test this ...
Comment #16
ydga commentedVery technical for me (designer) Im using Image Caption + CKEditor the left/right float is not transfered to the style of the caption container (image-caption-container-XXX) Im reading all your solutions, but I dont know where to start.
Comment #17
bryancasler commentedydga, checkout #1353198: Improvements to Image Caption's JS
Comment #18
NenadP commentedI did this fusion of original code and Anrikun suggestion from #1, because text near the image was going through the caption text, with original code.
But the Anrikun solution was not completely good for me, because i use colorbox (lightbox plugin). When i was back from colorbox popup, the code was appending another caption text.
This was originally prevented by adding .caption-processed.
So i did quick fusion of two codes working for me. Someone maybe could find it useful:
Comment #19
avpadernoI am closing this issue, which is for a not-supported Drupal version.