Blog Article


Craft CMS Plugin: Flickr Connect to Show the Stats, Part 1

This is Part 1 of a two-part article describing the custom Craft CMS plugin that I created to collect the statistics from Flickr's API. This article will introduce the objectives and desired results plus the introduction of creating the plugin. The second article will cover more technical details for this custom addon.

Do people still use Flickr? Yes, they do! 

Part 1 covers these topics: 

  • Objectives 
  • Results
  • Flickr's API
  • Basic Craft CMS Plugin Introduction


The main objectives for this plugin was to provide Flickr data information for the images on a website's portfolio and blog pages. The information to include are:

  • total views
  • total favourites
  • avatars of those who favoured the image
  • total comments
  • comments list with the avatar of the commenter

External information that I need to build this plugin:

  • Flickr API key
  • Matching Image Number


The fictional town Storybrooke, for the TV Show "Once Upon A Time", is filmed in a quaint little area called Steveston, in Richmond, a city south of Vancouver, BC. This image had many views, favorites [proper spelling for American friends], and comments on Flickr. 

On your portfolio page or blog, you can show off your impressive Flickr stats using this custom addon or plugin. Or in the case of the next photo, not so impressive...

This next image was taken at a Vancouver Mini MakerFaire event of a vehicle designed to use solar power. Here, you can see, it has less views, favourites, and comments. 

Now, to more technical details.

Flickr API

To get information from Flickr's system into your website, you'll need a Flickr API key. As of this writing, login to your Flickr Account and go to your Flickr Sharing & Extending section to see the link to register an API key or it could be under

The  API Documentation is well laid out with examples. 

One method that is used in the plugin is This method will return the list of people who have favourited a given photo. Because this is public information, authentication is not required, only the API key and the photo id number. You can explore this method by passing the required information and request the output as JSON to see the data that is returned. 

Basic Craft CMS Plugin Introduction

To get started, use these two resources:

Setup Plugin Structure

You'll set up your plugin structure and folders. Something like this:


Save User Settings

In MyPlugin.php, you'll need to setup a method to defineSettings(), something like this:

protected function defineSettings()
  return array(
    'myVar' => array(AttributeType::String,
      'required' => true,
      'label' => 'API Key',
      'default' => Craft::t('Paste API key here')

You'll also need the getSettingsHtml() method.

In /templates/_settings.html, use the examples to customize your settings page to save the user's API key.


For this plugin, I needed a model of the information that will be collected, such as the Flickr photo number, the number of views, favourites, and comments for each photo. 

To do this, I created the file /models/MyPluginModel.php and created a method defineAttributes(). This method needed to define the Attribute Type for favourites and comments which will have the value as json.

Contact us for web development.

Continue reading Craft CMS Plugin: Flickr Connect, Part 2 >

You May Also Like

The use of any third-party logos/trademarks does not indicate endorsement, association, affiliation, or sponsorship of the trademark holders or of their products & services by 3 Red Kites Studio Inc., nor vice versa.

Craft CMS, WordPress, Drupal, Perch CMS, Laravel, Twig, Symfony, ExpressionEngine, CodeIgniter, et al, are trademarks registered to their respective owners.