post

I’ve been using a great plugin called Dots to get a photo feed from Flickr, but for a while now I’ve been wanting to switch to 500px. So I decided to get my hands dirty, read the documentation and make my own plugin, so here is what I came up with.

The plugin requires the use of a consumer key, which you can obtain by visiting http://500px.com/settings/applications and registering a new application.

Stream option

In the sample below we will output 8 small photos from my profile linked to the detail pages on 500px website. The following options are available:

  • consumer_key: Your API consumer key, (required).
  • feature: The type of stream to request, defaults to user, (optional).
  • user: username to pull photos from, (required only if feature is set to user, user_friends or user_favorites).
  • count: Amount of photos to request, defaults to 5, (optional).
  • image_size: size of the image to be shown, it defaults to 3 (280 x 280), (optional).
  • sort: Sort photos in the specified order, (optional).
  • only: String name of the category to return photos from, (optional).
  • exclude: String name of the category to exclude photos by, (optional).

For details about option values and response format check the documentation for GET photos.

Code example


{{ fhpics:photos count="8" image_size="1" consumer_key="<your_key>" user="ramono" }}
    {{ photos }}
    <a href="http://www.500px.com{{ url }}">
        <img src="{{ image_url }}" alt="{{ name }}">
    </a>
    {{ /photos }}
{{ /fhpics:photos }}

Output

Frankfurt am Main Strada Sforii Reflections of Blackfriars Waiting Rainy Blackfriars Bridge Millennium Bridge Le Tunnel Rush Hour

Individual option

In this example we pull an individual photo. The available options are:

  • consumer_key: Your API consumer key, (required).
  • id: ID of the image, (required).
  • image_size: size of the image to be shown, it defaults to 3 which is 280px x 280px, (optional).
  • comments: Pull image comments, if omitted comments are not available, (optional).

For information on option values for the individual photo and response format check the documentation for Get photos/id.

Code example


{{ fhpics:photo id="49017066" image_size="4" comments="1" consumer_key="<your_key>" }}
<figure>
    <a href="http://www.500px.com{{ url }}" target="_blank">
        <img src="{{ image_url }}" alt="{{ name }}">
    </a>
    <figcaption>
        {{ description }}<br>
        {{ camera }} {{ shutter_speed }}s f{{ aperture }} ISO{{ iso }}
    </figcaption>
</figure>
{{ /fhpics:photo }}

Output

One Canada Square
Canary Wharf, in the heart of London
NIKON D5200 1/800s f5 ISO640

The plugin is a basic interface for the 500px API, and includes only a few options that should cover most use cases. The API is powerful enough to return many different stream options and a full array of information for each photo, including exif, author and all comments with their authors.

You can find the plugin in its Github page, free and open.

It is by no means finished. There are a few things I’d like to add like a profile option, make better use of the API options and maybe add collections as well. This is a work in progress, I hope you find it useful.

Previous article Next article

Comments

blog comments powered by Disqus