2017 Project: Photo Year

Pictures launch stories. I take a lot of photos and like most people, they stay on my phone. I used to use Instagram, but I'm not happy with their terms or use limitations on photos (ever tried to embed an image? It's a nightmare). Maybe I'm an idealist and this is a funk, but whatever.

I'm posting to Flickr more and more regularly and I decided to make a small project for 2017. I'm going to tag a photo each day that will push it and the description over to a new blog I'm calling The Photoyear. It'll syndicate that photo (technical stuff below) and turn it into a blog post. You can subscribe via RSS over there if you'd like. Sometimes, I'll cross post it here, but that will be a place for pictures and their stories for the next year.

Thanks, as always, for reading.

Setting up Flickr syndication

I started by writing more descriptive...descriptions...with my photos. That led to the idea of running a blog entirely on photos - content and all. Since I'm already doing that on Flickr, it made sense to try and syndicate it back to a blog of some kind. Alan Levine is the king of all things RSS. Some of his posts led to working solutions.

Recently, Alan posted where to find the Flickr RSS feed for public photos. Instead of grabbing everything I post (often more than one photo per day) I wanted to grab just one. I was going to manage that by adding photos to an album, but you can't do that anymore (not with an RSS URL, anyways). Sad trombone. So, I stick to tags.

I fired up a subdomain - photoyear.ohheybrian.com and installed WordPress and the FeedWordPress plugin to syndicate posts from any RSS feed. Running out of the box, it grabs the <description> tag only from the XML:

The immediate problem is the size of the embedded image. The src attribute is https://farm1.staticflickr.com/543/31231759933_ba613deec1_m.jpg, meaning the medium sized image is embedded, which is tiny. I had to get brave and check out a PHP solution.

In functions.php, I added a new filter (thanks to the suggestion of...you guessed it...Alan) which simply changes the _m.jpg to _b.jpg for a nice, full-width image.

I'm still not totally happy with my PHP solution because each post is going to come with, "a new photo by bennettscience" appended at the top. I tried using a preg_replace function to find the string and remove it (it's always the same), but I didn't have any luck. If you have a suggestion, I'd love some help figuring that snippet out.

Anyways, all said and done, you can check out The Photoyear now and then to see what's up. I'm looking forward to reading back over everything as we move through 2017.

6 thoughts on “2017 Project: Photo Year

  1. Alan Levine says:

    Very cool idea Brian,

    I’m not seeing the “a new photo by bennettscience” so maybe you fixed it?

    FYI, you don’t need to use preg_match when its an exact search and replace; it’s better to use str_replace (and I would use the file extension in case you have some content that for some reason has a “_m” in it, highlt unlikely, but still).

    Maybe try

    $content = str_replace( ‘_m.jpg’, ‘_b.jpg’, $content);

    • Brian Bennett says:

      Thanks for the suggestion on using str_replace instead of regex. Right now, FWP is set to put syndicated posts as Pending, so I went back with this one and removed the line. I was using,

      add_filter( 'the_content', 'edit_content');
      function edit_content($content) {
      $content = str_replace("bennettscience posted a photo: ", " ",$content);
      return $content;

      but I think the PHP is queuing something funny. I tried combining it with the image replace function, but I got some errors. I need to set up a sandbox page where I can test away somewhere without too much fuss.

      Like I said, I might be making this more of a chore than it’s worth in the long run.

      • Alan Levine says:

        Can’t help much without knowing the errors. You could try, though it should not be necessary, writing 2 different filter functions to do each task.

        Also, instead of running it on the content any time, you could try hooking into save_post so it just edits the post and that way it need not run every time. 1/2 a dozen vs 6.

        And I know about the chore thing on a tiny detail no one will likely every notice, but in the long run you are picking up some chops.

        • Brian Bennett says:

          I tried two filters, no dice, which is why I thought it might be something with PHP queuing the scripts differently. There are no errors, either, which is why I’m a little fuzzled. I gave in and asked on StackOverflow to try and gain some insight.

          Still learning…you’re saying use add_action( ' save_post ', 'edit_content_img') rather than the filter?

          • Alan Levine says:

            You maye want to add a $priority parameter to your add_filter statements- there might be a conflict with other hooks into that – like

            add_filter( ‘the_content’, ‘edit_content’, 20);

            The default is 10 so a higher number means it happens after other filters.

        • Brian Bennett says:

          Well, after more digging, I’ve discovered that FWP is adding n number of tabs in the post, making it difficult to match. I’ll stick with manual deletion for now.

Leave a Reply

Your email address will not be published. Required fields are marked *