Jump to content

Extension:FlickrImporter

From mediawiki.org
MediaWiki extensions manual
FlickrImporter
Release status: beta
Implementation Parser function , Special page
Description Allows for importing photos from Flickr
Author(s) Sam Wilson (samwilsontalk)
Latest version 0.1.0 (2018-05-03)
MediaWiki 1.30+
PHP 5.5+
Database changes No
Composer samwilson/flickr-importer
License GNU General Public License 3.0 or later
Download
CHANGELOG
  • $wgFlickrImporterKey
  • $wgFlickrImporterSecret

The FlickrImporter extension allows for importing photos from the social photograph sharing website Flickr.

Installation

[edit]
  • Download and place the file(s) in a directory called FlickrImporter in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'FlickrImporter' );
    $wgFlickrImporterKey = '<key here>';
    $wgFlickrImporterSecret = '<secret here>';
    
  • Register a new app on Flickr: https://www.flickr.com/services/apps/create/
  • Add your new API key and secret to LocalSettings.php
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage

[edit]
  1. Log in to MediaWiki, go to your user Preferences page, and click on the 'Misc' section
  2. Click on the 'Connect to Flickr' link, and follow the prompts (you'll be sent to Flickr, asked to authenticate, and then returned to your wiki)
  3. Your Flickr connection will be saved, so you won't have to do this again unless you disconnect
  4. Add your import definitions to User:<Username>/FlickrImporter.json (where <Username> is your username; there's a link to your import page on the Preferences page)

Import definitions are JSON-formatted objects containing the following information:

  1. description: Informative text about this import. Optional.
  2. type: one of: user, group, album, or gallery.
  3. id: ID or username of user; or ID of group, album, or gallery.
  4. privacy: an array of privacy levels (see below). Defaults to 1 just to be safe.
    • 1 public photos (the default)
    • 2 private photos visible to friends
    • 3 private photos visible to family
    • 4 private photos visible to friends & family
    • 5 completely private photos

For example, the complete contents of User:CommonsLover/FlickrImporter.json could be:

[
  {
    "description": "My photos",
    "type": "user",
    "id": "CommonsLover"
  },
  {
    "description": "Wikimedia Commons group",
    "type": "group",
    "id": "30009679@N00"
  }
]

Magic word

[edit]

This extension adds a new magic word: {{FLICKRID:1234}} that renders as a link to the given photos Flickr page, e.g. <span class="flickr-id">Flickr ID: <a href="https://flic.kr/p/nh">1234</a></span>. The text of the link can be modified via the flickrimporter-flickrid-link system message.

Template

[edit]

Each photo will be imported and have the following template added to its File page:

{{photo
 | title = 
 | description = 
 | author = 
 | date_taken = 
 | date_taken_granularity = 
 | date_published = 
 | latitude = 
 | longitude = 
 | license = 
 | privacy = 
 | flickr_id = 
}}