Captions on right side of image
-
Hi all,
I’m working on a child theme of twenty twelve where I would like the image caption to appear to the right of actual image. I’ve been looking at other older blog posts including this one:
https://www.ads-software.com/support/topic/captions-on-the-right-side-of-image?replies=6
The code I got from there is this (put in functions.php of child theme) but is two years old, so maybe things need to be changed(?):
/* * move captions to right of image */ add_shortcode('wp_caption', 'fixed_img_caption_shortcode'); add_shortcode('caption', 'fixed_img_caption_shortcode'); function fixed_img_caption_shortcode($attr, $content = null) { // Allow plugins/themes to override the default caption template. $output = apply_filters('img_caption_shortcode', '', $attr, $content); if ( $output != '' ) return $output; extract(shortcode_atts(array( 'id'=> '', 'align' => 'alignnone', 'width' => '', 'caption' => ''), $attr)); if ( 1 > (int) $width || empty($caption) ) return $content; if ( $id ) $id = 'id="' . esc_attr($id) . '" '; return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: ' . ((int) $width+ 299 + 20) . 'px"><span style="float:left;">' . do_shortcode( $content ) . '</span><p style="float:right; width: 301px;" class="wp-caption-text">' . $caption . '</p><span style="float:none;clear:both;display:block;"></span></div>'; }
It partly works… the image caption moves to the right of the image but all styling is removed and it aligns at the baseline of the image. I would like the caption to align to the top of the image so that the text fits nicely beside the image. Here is the link to the page:
https://www.bmc.med.utoronto.ca/cranialnerves_01/?page_id=22
I am new to wordpress, so I apologize if the fix is logical. Thank you for your help!
- The topic ‘Captions on right side of image’ is closed to new replies.