WordPress.org

Forums

Credit Tracker
[resolved] Featured Images (5 posts)

  1. mgk
    Member
    Posted 1 year ago #

    Can I get this to work with featured images?

    Or, is there a way to retrieve the extra fields like 'credit-tracker-author' so that I can insert them manually?

    Thanks,
    Mark

    https://wordpress.org/plugins/credit-tracker/

  2. mgk
    Member
    Posted 1 year ago #

    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));

  3. labs64
    Member
    Plugin Author

    Posted 1 year ago #

    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

  4. metapha
    Member
    Posted 9 months ago #

    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);
  5. metapha
    Member
    Posted 9 months ago #

    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);

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Credit Tracker
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.