EXIF data in custom RSS Feed
-
Hello,
I was wondering if there is a way to display EXIF data in my RSS feed?
Thanks.
-
@joshmbuck This should happen automatically; that is, the content added to a post should also be added to the feed content.
Do you mean that you want to add this information to the feed, but not to the post as shown on the site?
@kristarella, thanks for the quick response. That’s correct. I have the EXIF data in a widget, so the only thing in the post itself is the image. I’m trying to use the RSS feed to drop some of my pictures into another website, but I want to include the EXIF data of those pics.
I’ve learned how to create a custom rss feed, but I can’t figure out how to tell it to include the EXIF data within that custom RSS feed.
@joshmbuck How are you making the custom feed? That might change how this works.
You will probably need to use PHP to add to the feed. It would be something like:
function custom_add_exif_to_feed($content) { if (is_feed()) { return $content . exifography_display_exif('all'); } else { return $content; } } add_filter('the_content','custom_add_exif_to_feed');
That code could go in a plugin like Code Snippets, or in your theme functions file, or a custom plugin file.
The content filter docs are here:
https://developer.www.ads-software.com/reference/hooks/the_content/I don’t know anything about coding…I’m trying to teach myself ??
I found a tutorial that had the code to put into the function.php file and then the code for the rss-myrssfee.php file. Now I’m just tinkering to get the EXIF data.
So I put the code above into the functions file, but how do I actually call it in the rss file? I’m thinking the tag can be anything so
<exif> </exif>
would work? but what do I put between to actually get it to work? I’ve triedexifography_display_exif
andcustom_add_exif_to_feed
and neither worked.Thanks.
@kristarella, I think I was going about this all wrong. As I’ve done more research, I realized that I don’t need to create a custom RSS, since all the data is there when I view my /feed site. BUT…I can’t figure out how to pull out just the specific EXIF data I want from all the content.
I have this in my page template
<div class="photo-info"> <h3 class="photo-title"><?php echo esc_html( $item->get_title() ); ?></h3> <h3 class="photo-caption"><?php echo esc_html( $item->get_description() ); ?></h3>
But the
get_description()
gives me everything. I’m assuming that I should put something between the perens, but I’m not sure what. I’ve triedexifography_display_exif
but that doesn’t work.Any ideas?
Here’s the full code if it helps:
<?php $feed = fetch_feed('https://www.mysite.com/feed/'); if (!is_wp_error( $feed ) ) : $maxitems = $feed->get_item_quantity( 12 ); $rss_items = $feed->get_items( 0, $maxitems ); endif; ?> <?php function get_first_image_url($html) { if (preg_match('/<img.+?src="(.+?)"/', $html, $matches)) { return $matches[1]; } } ?> <?php if ($maxitems == 0) echo '<li>No items.</li>'; else foreach ( $rss_items as $item ) : ?> <article class="photos"> <a target="_blank"href='<?php echo esc_url( $item->get_permalink() ); ?>'> <div class="photo-image"> <?php echo '<img src="' .get_first_image_url($item->get_content()). '"/>'; ?> </div><!--.photo-image --> <div class="photo-info"> <h3 class="photo-title"><?php echo esc_html( $item->get_title() ); ?></h3> <h3 class="photo-caption"><?php echo esc_html( $item->get_description() ); ?></h3> </div><!--.photo-info --> </a> </article> <?php endforeach; ?>
I want
get_description
to display my camera, focal_length, shutter_speed, and aperture.Thanks.
- This reply was modified 4 years, 1 month ago by Josh.
- The topic ‘EXIF data in custom RSS Feed’ is closed to new replies.