I suggest you ...

Flickr integration

It would be great it we could just enter a username or album id and it creates a gallery automatically.

17 votes
Vote
Sign in
(thinking…)
Password icon
Signed in as (Sign out)
You have left! (?) (thinking…)
Ignacio shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

1 comment

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • Ricardo Santos commented  ·   ·  Flag as inappropriate

    I have done it.
    It works but it's not an elegant solution.

    <div class="row">
    <div class="demo-gallery" data-pswp-uid="1">














    <?
    #
    # build the API URL to call
    #

    $apikey = 'INSERT-YOUR-API-KEY-HERE';
    $photoset_id = 'INSERT-YOUR-PHOTOSET-ID-HERE';

    # You need to get an API Key from flickr.
    $params_list = array(
    'method' => 'flickr.photosets.getPhotos',
    'api_key' => $apikey,
    'photoset_id' => $photoset_id,
    'extras' => 'description',
    'format' => 'php_serial',
    );
    $encoded_params_list = array();

    foreach ($params_list as $k => $v){
    $encoded_params_list[] = urlencode($k).'='.urlencode($v);
    }

    #
    # call the API and decode the response
    #

    $url = "https://api.flickr.com/services/rest/?".implode('&', $encoded_params_list);
    $rsp_list = file_get_contents($url,false);
    $rsp_list_obj = unserialize($rsp_list);

    #

    # display the photo title (or an error if it failed)
    #

    if ($rsp_list_obj['stat'] == 'ok')
    {
    $photos = $rsp_list_obj["photoset"]["photo"];
    foreach($photos as $photo)
    {
    $photo_id = $photo['id'];

    $photo_title = $photo['title'];
    $description = $photo ['description']['_content'];

    $params = array(
    'method' => 'flickr.photos.getSizes',
    'api_key' => $apikey,
    'photo_id' => $photo_id,
    'format' => 'php_serial',
    );

    $encoded_params = array();

    foreach ($params as $k => $v){
    $encoded_params[] = urlencode($k).'='.urlencode($v);
    }

    #
    # call the API and decode the response
    #

    $url = "https://api.flickr.com/services/rest/?".implode('&', $encoded_params);
    $rsp = file_get_contents($url,false);

    $rsp_obj = unserialize($rsp);

    if ($rsp_obj['stat'] == 'ok')
    {
    #print_r($rsp_obj);
    $sizes = $rsp_obj["sizes"]["size"];

    #$label = $photo['label'];
    #Large 2048
    #$sizes[10]["label"];

    $urlsquare75 = $sizes[0]["source"];
    $urlsquare75_w = $sizes[0]["width"];
    $urlsquare75_h = $sizes[0]["height"];

    $urlsquare150 = $sizes[1]["source"];
    $urlsquare150_w = $sizes[1]["width"];
    $urlsquare150_h = $sizes[1]["height"];

    $url100 = $sizes[2]["source"];
    $url100_w = $sizes[2]["width"];
    $url100_h = $sizes[2]["height"];

    $url240 = $sizes[3]["source"];
    $url240_w = $sizes[3]["width"];
    $url240_h = $sizes[3]["height"];

    $url320 = $sizes[4]["source"];
    $url320_w = $sizes[4]["width"];
    $url320_h = $sizes[4]["height"];

    $url500 = $sizes[5]["source"];
    $url500_w = $sizes[5]["width"];
    $url500_h = $sizes[5]["height"];

    $url640 = $sizes[6]["source"];
    $url640_w = $sizes[6]["width"];
    $url640_h = $sizes[6]["height"];

    $url800 = $sizes[7]["source"];
    $url800_w = $sizes[7]["width"];
    $url800_h = $sizes[7]["height"];

    $url1024 = $sizes[8]["source"];
    $url1024_w = $sizes[8]["width"];
    $url1024_h = $sizes[8]["height"];

    $url1600 = $sizes[9]["source"];
    $url1600_w = $sizes[9]["width"];
    $url1600_h = $sizes[9]["height"];

    $url2048 = $sizes[10]["source"];
    $url2048_w = $sizes[10]["width"];
    $url2048_h = $sizes[10]["height"];

    }



    #$imgmain = ($photo_id == 16447955216)?"class=\"demo-gallery__img--main\"":"";

    ?>
    <a href="<?=$url2048?>" data-size="<?=$url2048_w?>x<?=$url2048_h?>" data-med="<?=$url1024?>" data-med-size="<?=$url1024_w?>x<?=$url1024_h?>" data-author="INSERT-YOUR-NAME-HERE" <?=$imgmain?>>
    <img src="<?=$url320?>" alt="<?=$photo_title?>">
    <figure><?=$description?></figure>
    </a>
    <?

    }
    }
    else
    {

    echo "Call failed!";
    }


    ?>






    </div>
    </div>

Feedback and Knowledge Base