WordPress.org

Ready to get started?Download WordPress

Forums

BlankSlate
[resolved] Caption Problem (9 posts)

  1. pinatasaur
    Member
    Posted 1 year ago #

    Hello there! I used this theme as a boilerplate for a site, and am having some problems with how captions are handled.

    On the page I'm editing, in the image panel, I put the text I want into the Caption field, and it looks like this in HTML view:

    [caption id="attachment_13" align="alignnone" width="300"]<img class="size-medium wp-image-13" alt="image" src="http://localhost/wordpress4/wp-content/uploads/2013/01/3whTg-300x300.jpg" width="300" height="300" /> Super Descriptive Caption Text! [/caption]

    Problem is, this does not get output as a caption on the page. It just shows up as text, not wrapped in any kind of paragraph tags or anything. After doing some reading, I found a workaround, which involves changing things around manually like this -

    [caption id="attachment_13" align="alignnone" width="300" caption="Super Descriptive Caption Text!"]<img class="size-medium wp-image-13" alt="image" src="http://localhost/wordpress4/wp-content/uploads/2013/01/3whTg-300x300.jpg" width="300" height="300" />[/caption]

    And then it will show correctly.

    But every time I swap back from HTML view to Visual view, it puts the caption text back where it put it in the first place, and it goes back to being broken. Yet, if I switch to the 2012 theme, the captions work.

    I put a test page up so you can see what I'm talking about without digging through a lot of content: http://mdpmco.com/glamoursmiles/testpage/

    The caption next to the picture of the dog ("This is a dog") is just text.

    Is this a problem with the way the theme handles the caption shortcode output? It doesn't seem to recognize the [caption]<image>Content of Caption Field[/caption] format that WordPress is using.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    Is this a problem with the way the theme handles the caption shortcode output?

    yes - there was a change to the caption code in one of the last new versions of wp;

    have a look into /wp-includes/media.php from line 628.

    your theme uses its own caption code which does not take those changes into consideration;

    in functions.php of your theme, change the corresponding section to the code below:

    function fixed_img_caption_shortcode($attr, $content = null) {
    $output = apply_filters('img_caption_shortcode', '', $attr, $content);
    if ( $output != '' ) return $output;
    	// New-style shortcode with the caption inside the shortcode with the link and image tags.
    	if ( ! isset( $attr['caption'] ) ) {
    		if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
    			$content = $matches[1];
    			$attr['caption'] = trim( $matches[2] );
    		}
    	}
    extract(shortcode_atts(array(
    'id'=> '',
    'align'	=> 'alignnone',
    'width'	=> '',
    'caption' => ''), $attr));
    ....

    (not widely tested)

  3. pinatasaur
    Member
    Posted 1 year ago #

    That does seem to work! Thank you.

    I'm going to go ahead and update the example I linked, but I put an example up here in case it's useful to look at: http://www.mdpmco.com/test/testblog/a-blog/ The dog picture and caption are the same.

  4. pinatasaur
    Member
    Posted 1 year ago #

    Tangentially, is there a way to make the caption dependent on the width of the image it's attached to? I'm sure this is just PHP ignorance on my part, but I can't figure out how to make this theme do it.

  5. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    your latest link does not actually show any wp-caption code (?)

    btw: I realized that I posted some code which does not seem to be in the latest version of the theme (version 3.1 updated 5 days ago).

    as you are using 3.0, possibly updating might help?

    genrally, the caption code should wrap the image and caption text into a container and thereby liniting the text to the width of the image;

    this is the corresponding section from the 3.1 version of the function code:

    return '<figure ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: '
    . (10 + (int) $width) . 'px">' . do_shortcode( $content ) . '<figcaption ' . $capid
    . 'class="wp-caption-text">' . $caption . '</figcaption></figure>';
  6. TidyThemes
    Member
    Theme Author

    Posted 1 year ago #

    That's correct. The captions were fixed about a week ago.

    But as you may or may not know, .org is primarily driven by volunteers in their free time, so it's about a week wait before an updated theme is pushed live for that to be seen on the main theme page and for you to get an update notice in your WP admin in order to automatically update.

    You can always check the SVN for the latest:

    http://themes.svn.wordpress.org/blankslate/

    and then just manually change the download URL to whatever version you need:

    http://wordpress.org/extend/themes/download/blankslate.3.1.zip

    But, you would need to manually upgrade as well.

    In this case, simply go to Dashboard > Updates in your WP admin.

    To get better help, quicker, please use the official forum in the future:

    http://tidythemes.com/forum/

    Thanks

  7. rjain
    Member
    Posted 11 months ago #

    To follow up on this. I just updated to version 3.5 and I am having the same issue. The captions are are showing up next to images. In the visual end of WP the image and caption looks fine but in preview or publishing it shows up next to image.

    I tried changing the code in text but it changes back. Here's the code in text.

    [caption id="attachment_8241" align="alignright" width="200"]<img class="size-full wp-image-8241 " alt="Obesity is a disease - changes to come?" src="http://www.livablefutureblog.com/wp-content/uploads/2013/06/RS65_girl-apples.jpg" width="200" height="300" /> Obesity is a disease - changes to come?[/caption]

  8. WPyogi
    Volunteer Moderator
    Posted 11 months ago #

    @rjain - see the post above yours from the theme author - he suggests you post in the theme's dedicated forums for faster help - here:

    To get better help, quicker, please use the official forum in the future:

    http://tidythemes.com/forum/

    Why not take advantage of that?

  9. TidyThemes
    Member
    Theme Author

    Posted 10 months ago #

    Version 4.0 is here:

    http://wordpress.org/themes/download/blankslate.4.0.zip

    Let us know what you think here:

    http://tidythemes.com/tidythemes-sucks/

    Thanks, TidyThemes

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic