• Resolved Eddie

    (@eddie6e)


    Your filters are brilliant and I have successfully tooled and tweaked my output the way I want it. I’m actually using the shortcode to display the exif by simply placing it in the image caption.

    All works well when displaying the exif info the image attachment pages, but not when displaying within a post. Some data I gather using wp_get_attachment_metadata($imgID). This data is what is missing on posts but displays fine on the attachment pages.

    What am I missing?

    function clean_exif($content,$postID,$imgID){
      unset($content['caption']);
      unset($content['title']);
      unset($content['created_timestamp']);]);
      $imgmeta = wp_get_attachment_metadata($imgID);
      $width= $imgmeta['image_meta']['width'];
      $height = $imgmeta['image_meta']['height'];
      array_push($content,$height . 'x' . $width);
    return $content;
    add_filter('exifography_display_exif','clean_exif');

    https://www.ads-software.com/plugins/thesography/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Eddie

    (@eddie6e)

    I posted the wrong code tidbit… Less junk and the correct array for width & height being used ?? Still works in the attachment page but not in posts.

    function clean_exif($content,$postID,$imgID) {
         $imgmeta = wp_get_attachment_metadata($imgID);
         $width = $imgmeta['width'];
         $height = $imgmeta['height'];
         array_push($content,'<li>' . $height . 'x' . $width . '</li>');
    return $content;
    }
    Plugin Author kristarella

    (@kristarella)

    It might be that you need to increase the number of parameters that are used in the filter. By default add_filter only uses the first argument (in this case $content) and you need to increase the number it’s using when you apply your function.

    I.e., add_filter('exifography_display_exif','clean_exif',10,3);

    If that’s the case I’m not sure why it would work on the attachment page and not others, but give this a go anyway.

    Thread Starter Eddie

    (@eddie6e)

    That was it exactly! That did the trick… you get the awesome developer support award for the day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘$imgID doesn't work with filters & shortcode’ is closed to new replies.