Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, I had a look at this module which provides a very common sense feature. One question though - why isn't it just implemented as a normal drupal filter? Why does it use js? That means it won't work for anyone that doesn't have js.
Just wondering because maybe it would be worth improving it to include an alternative option. Or coding a separate module.
Comment | File | Size | Author |
---|---|---|---|
#12 | image_caption_filter.tar_.gz | 1.38 KB | fletchgqc |
#4 | image_caption_filter.tar_.gz | 1.38 KB | fletchgqc |
Comments
Comment #1
davidwhthomas CreditAttribution: davidwhthomas commentedYes, it could work too as an input filter.
I may include a input filter option as a sub-module, but feel free to submit a patch ;-)
regards,
DT
Comment #2
fletchgqc CreditAttribution: fletchgqc commentedYeah I might give it a go if I have some time after the intensive project I'm on right now is finished. There are a few other things I'd like to add like using the title text as alt text if there is no alt text.
I've never parsed HTML with PHP. Do you know where I can look for help? Are there any handy functions to extract elements and attribute values from a HTML document?
Comment #3
davidwhthomas CreditAttribution: davidwhthomas commentedI've already made an input filter that processes attached images and embeds them using imagecache and lightbox. It uses an [image] tag in the text and swaps it with a scaled image with lightbox popup and caption. You can see it on http://odt.co.nz
But... If the filter was going to caption embedded images, it may need to parse the html. This would be done using regular expressions which are kinda complicated but do the job perfectly too.
More info on regular expressions is here:
http://en.wikipedia.org/wiki/Regular_expressions
or:
http://php.net/preg_match
regards,
DT
Comment #4
fletchgqc CreditAttribution: fletchgqc commentedAttached is a module in its own right called "image_caption_filter".
It basically works like image_caption but it does the work by modifying the HTML code rather than using JS.
Due to the static class names and the pink warning text it's not really ready for the prime-time. I think it needs configuration options for the class names of this form: if image has class [configurable], add class [configurable] to the containing div, remove class from image [yes/no].
Additionally: class applied to caption divs: [configurable].
If someone added that I think it could totally replace the js version. (?)
BTW how is your CVS access going? What needs to be sorted and when do you think this might happen?
Comment #5
davidwhthomas CreditAttribution: davidwhthomas commentedThanks v.much for this.
I will look at integrating it into image_caption.
I'm still waiting on a drupal admin to clean out my CVS D6 branches so I can start again.
At the moment, I can't submit any D6 patches :-(
But, it should be sorted in the near future.
regards,
DT
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commented@fletchgqc: Good work. I prefer the filter instead of the module b/c no edit of the theme is required.
Now we need a smaller font for the caption text.
Comment #7
davidwhthomas CreditAttribution: davidwhthomas commentedYou don't need to edit the theme for the jQuery version.
As long as you can give the image a class of 'caption' it will work.
You can do that when entering the content also.
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedYou're right. I've misread the documentation. Nevertheless, a filter would be a good choice.
Comment #9
fletchgqc CreditAttribution: fletchgqc commentedI found out that my filter makes your code not XHTML strict anymore. I'm going to remedy this. Do you want the patch? What is going on with this module anyway?
Surely it can't take that long to get CVS sorted out.
Should I use my code to start another module instead?
Comment #10
davidwhthomas CreditAttribution: davidwhthomas commentedHi there,
Yes, please submit the patch.
Apologies on the delay, I've been snowed under at work and this has been put on the back burner.
If you send it through I'll look at getting it added over this weekend.
regards,
DT
Comment #11
davidwhthomas CreditAttribution: davidwhthomas commentedcommited to DRUPAL-6--2 branch.
http://drupal.org/node/298044
Comment #12
fletchgqc CreditAttribution: fletchgqc commentedThanks David,
Attached is another version where I replaced the divs with spans.
The problem is that a div inside a p tag is invalid XHTML strict! So I changed them to span and personally I style them as display: block in my CSS. A bit ridiculous but it works and it's valid.
Sorry for uploading .tar.gzs instead of a patch... anyway I wouldn't necessarily commit this. It's just for info. I think we need to tackle this properly with some config options. I will look into this once internet is working at my home again!
Comment #13
davidwhthomas CreditAttribution: davidwhthomas commentedCool, thanks John,
I'll patch this update in shortly.
regards,
DT
Comment #14
mansspams CreditAttribution: mansspams commentedI wanted to suggest this filter to not use custom class names to identify images for caption magic if imagefield/CCK workflow is used but...
don't bother to help... imagefield/CCK approach inserts images in nodes below or above body field data on which input filters work, therefore image_caption_filter will not work on those images even in theory.
Comment #15
RichieRich CreditAttribution: RichieRich commentedHi there,
I can't get the image_caption_filter module to do anything at all. Just to be clear, am I right in thinking that all I have to do is add, for example, an 'image-left' class to the img for it to work?
Do I require both this module and the JQuery module to be enabled? I've tried both combinations but with no joy.
I've tried clearing the cache etc with no effect.
Here's an example where I've applied the 'standalone-image' class. It's the top image on this page:
http://www.ishigaki-japan.com/culture/haari
As you can see there's no caption (unless of course I've managed to fix it by the time you read this post).
Any help would be greatly appreciated.
Regards,
Rich
Comment #16
Geijutsuka CreditAttribution: Geijutsuka commentedYeah... I'm having the same problem- I must be missing something, but what?
Comment #17
bradweikel CreditAttribution: bradweikel commentedFor those having issues with the filter not working at all, check out #692374: Filter doesn't work on images with multiple classes and see if that's the problem. If not, try to pin down the specific problem and file a new issue.
Comment #18
vood002 CreditAttribution: vood002 commentedAlthough #17 is still important to look at, be sure that you've also activated this filter for every input format you want to use it with on /admin/settings/filters/list first...I don't believe this is called out anywhere for image_caption_format.
Comment #19
NPC CreditAttribution: NPC commentedI need to test this for my site, I really like the general idea of using a filter, but it may be too rigid (I don't want all of the existing images suddenly having pink captions, since there are hundreds of them). Subscribing.
Comment #20
NPC CreditAttribution: NPC commentedIt does work as needed, thank you very much! (especially with the patch to configure class to use and to handle multiple classes with images). This is a great module!
Comment #21
captnaimerica CreditAttribution: captnaimerica commentedI can't get the caption to align with the image when I float it left or right, I've read a lot of posts, but I was wondering what the best way to do it is? I went and applied this patch http://drupal.org/files/issues/image_caption.js_.patch but its still not working.
Comment #22
alberto facchini CreditAttribution: alberto facchini as a volunteer commentedI'm trying to use the Image caption module. All is working, but the caption has not enough space between the body text. How can I do to give more space? Can I write something in the CKeditor CSS or somewhere else?