Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mgk

    (@mgk)

    Just in case anyone else is looking for this I worked out I can use this code;

    $image[‘author’] = wptexturize(get_post_meta(get_post_thumbnail_id($post->ID),’credit-tracker-author’,true));

    Plugin Author labs64

    (@labs64)

    Hi mgk,

    Thank you for your interest to our plugin and prompt investigation.
    You are completely right, using provided code snippet you can access additional information stored by Credit Tracker plugin.

    Further you can always refer to the source code of the plugin:
    https://github.com/Labs64/credit-tracker/blob/master/credit-tracker-functions.php
    … function get_images() for instance shows how to access this information.

    Best Regards,
    Labs64

    Hi Labs64,

    I used the above information to retrieve the credit tracker author and source. But after I upgraded the plugin to the latest version, it doesn’t work anymore.

    I used this code in the functions.php – has there been any changes?

    Regards

    // Thumbnail Caption
    function monahans_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr)
    {
      $attachment =& get_post($post_thumbnail_id);
    
      // post_title => image title
      // post_excerpt => image caption
      // post_content => image description
    
      if ($attachment->post_excerpt || $attachment->post_content) {
        $html .= '<p class="thumbcaption">';
        if ($attachment->post_excerpt) {
          $html .= '<span class="captitle">'.wptexturize(get_post_meta(get_post_thumbnail_id($post->ID),'credit-tracker-author',true)).'</span> ';
        }
        $html .= "?".wptexturize(get_post_meta(get_post_thumbnail_id($post->ID),'credit-tracker-source',true))."/".wptexturize(get_post_meta(get_post_thumbnail_id($post->ID),'credit-tracker-author',true)).'</p>';
      }
    
    	return $html;
    }
    
    add_action('post_thumbnail_html', 'monahans_thumbnail_caption', null, 5);

    I found the error, both if statements are redundant (I believe I had changed that before and my client copied an old version from a backup).

    Anyway, this works:

    // Thumbnail Caption
    function monahans_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr)
    {
      $attachment =& get_post($post_thumbnail_id);
    
      // post_title => image title
      // post_excerpt => image caption
      // post_content => image description
    
        $html .= '<p class="thumbcaption">';
        $html .= "&copy;".wptexturize(get_post_meta(get_post_thumbnail_id($post->ID),'credit-tracker-source',true))."/".wptexturize(get_post_meta(get_post_thumbnail_id($post->ID),'credit-tracker-author',true)).'</p>';
    
    	return $html;
    }
    
    add_action('post_thumbnail_html', 'monahans_thumbnail_caption', null, 5);
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Featured Images’ is closed to new replies.