#6812 closed enhancement (fixed)
Image captions
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | normal | Version: | 2.5 |
Component: | Administration | Keywords: | has-patch |
Focuses: | Cc: |
Description
Once #6811 is in, a great enhancement to the unified image editor would be the ability to have a caption, and for that to be inserted in a standard easy-to-style way. Here's a great use of image captions:
http://politicalticker.blogs.cnn.com/
We already have a caption field, it's just a matter of exposing that data with the image, maybe shortcode style?
Attachments (9)
Change History (45)
#2
@
17 years ago
- Keywords has-patch added
Support for image captions, first run. Uses shortcode around the img tag for the caption's settings, so
<img/> or <a><img /></a>
becomes
[wp_caption]<a><img /></a>[/wp_caption]
This way seems most compatible and at the same time futureproof. Any king of tags can be generated while processing the shortcode, or if captions are not needed, the shortcode can be filtered out and the default tag(s) returned.
Currently the captions are rendered similarly to the gallery page:
<dl> <dt><a><img /></a></dt> <dd>caption text</dd> </dl>
This is supported in both TinyMCE and on the blog. All images that have alt text (attachment excerpt) will have captions when inserted in the editor. Also while editing older posts, if the images are edited and have alt text, the caption will be added. To stop showing caption for an image, the caption text should be deleted while editing the image (with the new popup), or the shortcode can be deleted from the HTML editor.
#3
@
17 years ago
The basic styles for the captions are in the Default and the Classic themes' style.css files. The users would have to copy/paste them in their current theme's style.css, similarly to the alignment classes.
#7
@
17 years ago
Fix for showing of raw shortcode in the editor: creates the caption HTML before inserting new image, rather than on TinyMCE cleanup.
#9
@
17 years ago
This patch includes several fixes: captions are properly created in tables and in lists, all tags are properly removed when deleting a caption, the "align" buttons can be used to align the captions.
#11
@
17 years ago
Fix for single and double quotes entered in the captions, also simplifies the HTML tags on the site, renames the css classes to use dashes.
#14
@
17 years ago
Caption styles in the default theme are not correct. Dashes instead of underscores, that sort of thing.
#15
@
17 years ago
Additional: My bad, I see that was intentional. Well, if you're going to use dashes, then you should probably make the shortcode actually produce them, because on trunk it's still making underscores and such.
#19
@
17 years ago
Support for disabling captions. To disable, define the constant DISABLE_IMAGE_CAPTIONS as true:
define('DISABLE_IMAGE_CAPTIONS', true);
either in wp-config.php or in the theme's functions.php.
#21
@
17 years ago
Agree, renamed to CAPTIONS_OFF, also renamed the shortcode to "caption" (the old one is still registered for back compat).
#22
follow-up:
↓ 26
@
17 years ago
You don't need a constant to not display the captions. Just either don't use the shortcode or hide them using CSS.
Instead of a useless constant, simply make a checkbox for captions on/off on the image insertion screen.
#25
@
17 years ago
Went with the patch to get the other changes. We change how disabling is done if need be.
#26
in reply to:
↑ 22
@
17 years ago
Replying to Otto42:
You don't need a constant to not display the captions. Just either don't use the shortcode or hide them using CSS.
Instead of a useless constant, simply make a checkbox for captions on/off on the image insertion screen.
It's very easy to stop displaying the captions on the blog. Registering an empty shortcode that returns the <img> tag would do it (the <img> tag is the content of the [caption] shortcode).
Not so easy to disable the adding of captions when inserting or editing an image in the editor though. Of course it can be done with another checkbox in the user's settings, or a checkbox/cookie from js, but that would make it harder for themes/plugins. They will have to support both states, disabled and enabled, as it would be an user setting.
#28
@
17 years ago
Removes the disabling of captions, but leaves couple of hooks so a plugin can do it easily.
#29
@
17 years ago
- Milestone changed from 2.9 to 2.6
- Resolution set to fixed
- Status changed from new to closed
#31
follow-up:
↓ 32
@
17 years ago
I don't even see why that filter hook for disable captions is necessary. You've already got a filter to replace the captions system entirely. So disabling captions is as easy as this:
function no_caption($deprecated, $attr, $content) { return $content; }; add_filter('img_caption_shortcode', 'no_caption', 10, 3);
Why have yet another useless filter hook?
#32
in reply to:
↑ 31
@
17 years ago
Replying to Otto42:
I don't even see why that filter hook for disable captions is necessary. You've already got a filter to replace the captions system entirely. So disabling captions is as easy as this:
function no_caption($deprecated, $attr, $content) { return $content; }; add_filter('img_caption_shortcode', 'no_caption', 10, 3);Why have yet another useless filter hook?
That would stop the captions from displaying on the site, but not in the visual editor and the user will still be able to enter them.
Have been thinking what's the best way to do this. Generally there seem to be four options:
easiest/most compatible way. Will only need few lines of css added to wp_head(). Disadvantages: cannot be removed later without editing the posts, no backwards compatibility.
Also think that we will need another checkbox in the miscellaneous settings to enable/disable the captions globally.