Australia's Leading Digital Marketing Experts. T. 1300 235 433  |  Aggreagtion Enquires Welcome

Return Licence Details for Flickr Images With PHP

This function will be referenced for various Flickr Tag: flickr related snippets and shortcodes we plan on sharing. The purpose of the function is to return licence details for particular images based on a numeric licence reference returned by Flickr. The function is intended to be used with the Flickr API or other platforms that honor their licence referencing.

1
<?php 
2
/*
3
    Return Licence Details for Flickr Images With PHP
4
    http://www.beliefmedia.com/code/php-snippets/flickr-licences    
5
*/ 
6
 
7
 
8
function beliefmedia_licensing_array($lic) {
9
 
10
  $licence = array();
11
 
12
   switch ($lic) {
13
 
14
     case '0':
15
       $licence['licence_name'] = 'All Rights Reserved';
16
       $licence['licence_url'] = 0;
17
       break;
18
     case '1':
19
       $licence['licence_name'] = 'Attribution-NonCommercial-ShareAlike License';
20
       $licence['licence_url'] = 'http://creativecommons.org/licenses/by-nc-sa/2.0/';
21
       $licence['licence_short'] = 'CC BY-NC-SA';
22
       break;
23
     case '2':
24
       $licence['licence_name'] = 'Attribution-NonCommercial License';
25
       $licence['licence_url'] = 'http://creativecommons.org/licenses/by-nc/2.0/';
26
       $licence['licence_short'] = 'CC BY-NC';
27
       break;
28
     case '3':
29
       $licence['licence_name'] = 'Attribution-NonCommercial-NoDerivs License';
30
       $licence['licence_url'] = 'http://creativecommons.org/licenses/by-nc-nd/2.0/';
31
       $licence['licence_short'] = 'CC BY-NC-ND';
32
       break;
33
     case '4':
34
       $licence['licence_name'] = 'Attribution License';
35
       $licence['licence_url'] = 'http://creativecommons.org/licenses/by/2.0/';
36
       $licence['licence_short'] = 'CC BY';
37
       break;
38
     case '5':
39
       $licence['licence_name'] = 'Attribution-ShareAlike License';
40
       $licence['licence_url'] = 'http://creativecommons.org/licenses/by-sa/2.0/';
41
       $licence['licence_short'] = 'CC BY-SA';
42
       break;
43
     case '6':
44
       $licence['licence_name'] = 'Attribution-NoDerivs License';
45
       $licence['licence_url'] = 'http://creativecommons.org/licenses/by-nd/2.0/';
46
       $licence['licence_short'] = 'CC BY-ND';
47
       break;
48
     case '7':
49
       $licence['licence_name'] = 'No known copyright restrictions';
50
       $licence['licence_url'] = 'http://flickr.com/commons/usage/';
51
       $licence['licence_short'] = 'NIL';
52
       break;
53
     case '8':
54
       $licence['licence_name'] = 'United States Government Work';
55
       $licence['licence_url'] = 'http://www.usa.gov/copyright.shtml';
56
       $licence['licence_short'] = 'USG';
57
       break;
58
     case '9':
59
       $licence['licence_name'] = 'Public Domain Dedication (CC0)';
60
       $licence['licence_url'] = 'https://creativecommons.org/publicdomain/zero/1.0/';
61
       $licence['licence_short'] = 'CC0';
62
       break;
63
     case '10':
64
       $licence['licence_name'] = 'Public Domain Mark';
65
       $licence['licence_url'] = 'https://creativecommons.org/publicdomain/mark/1.0/';
66
       $licence['licence_short'] = 'PDM';
67
       break;
68
     default:
69
       $licence['licence_name'] = 'All Rights Reserved';
70
       $licence['licence_url'] = 0;
71
       $licence['licence_short'] = 'C';
72
       break;
73
   }
74
 
75
 return $licence;
76
}

1
<?php 
2
/* Test Usage */
3
echo print_r(beliefmedia_licensing_array('2'), true);

An example response is as follows:

1
Array
2
(
3
    [licence_name] => Attribution-NonCommercial License
4
    [licence_url] => http://creativecommons.org/licenses/by-nc/2.0/
5
    [licence_short] => CC BY-NC
6
)

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on Linkdin
Share on pinterest
Share on Pinterest

Leave a comment