Walker News

How To Change WordPress Image Caption Text Style To Superscripts?

WordPress 2.5+ rewrite the image/file uploader interface to include some most wanted features, e.g. multiple images per single upload, WordPress Gallery Shortcode, image caption text, image size and alignment, etc.

Question: How could you force WordPress image caption text to appear as superscripts text style, rather than sharing the common post body text style?
What is that superscripts text style?

Superscripts text style is usually 75% smaller than its original size and appears at upper position of the same text line, e.g. the blue colour text in WalkerNews or 7th.

Why rendering WordPress image caption text in superscripts style?

Image caption text is deemed as “alternative text” of an image, i.e. text that describes the image (so that search engine knows what is the image about. That’s why you should write little text for the image alt=”” attribute!

If the article itself is enough to tell story of the image, I think it’s better to “hide them” or just display the caption text in superscripts style for better reading experience or presentation.

How to get WordPress 2.6.1 to display image caption text in superscripts style?
  1. Edit wp-includes/media.php file
     
  2. Look for this function img_caption_shortcode($attr, $content = null)
     
  3. Change this line
    . $content . '<p class="wp-caption-text">' . $caption . '</p></div>';

    to become
    . $content . '<br /><sup>' . $caption . '</sup></div>';

There are at least 3 media.php files in 3 different directories, and this WordPress mod is using the wp-includes/media.php.

If you can’t find the mentioned function, make sure you’re editing the right media.php file. Otherwise, this trick is only tested in WordPress 2.6.1 (and might not working in other version?). Good luck.

Custom Search

  1. WordPress: Adds wp-caption-text To CSS File For Image Caption Styling – Walker News 11-09-08@01:20

    […] there a WordPress plugin or alternative ways than editing wp-includes/media.php file if I want to format WordPress image caption text? Answer: Yes. There are many ways to Rome, and editing WordPress core file is certainly not the […]

2014  •  Privacy Policy