doubi2228 2010-04-01 15:21
浏览 100
已采纳

flickr phpflickr api

Overview
I am trying to get a photo feed on to my site using Flickr's api and the phpflickr library. I can successfully get the photoset on to my site, but it shows all the photos from every photoset, what I was hoping to achieve was to show the primary photo from each photoset, and then if the user clicked on the image it would show the full photoset in a lightbox/shadowbox.

My Code

<div id="images" class="tabnav">
                    <ul class="items">
                        <?php $count = 1; ?>
                        <?php foreach ($photosets['photoset'] as $ph_set): ?>
                        <?php $parentID = $ph_set['parent']; ?>
                          <?php $photoset_id = $ph_set['id'];
                          $photos = $f->photosets_getPhotos($photoset_id);
                          foreach ($photos['photoset']['photo'] as $photo): ?>
                           <li>
                           <a rel="shadowbox['<?=$count;?>']" href="<?= $f->buildPhotoURL($photo, 'medium') ?>" title="<?= $photo['title'] ?>">
                                <img src="<?= $f->buildPhotoURL($photo, 'rectangle') ?>" alt="<?= $photo['title'] ?>" width="210" height="160" title="<?= $photo['title'] ?>" />
                                <h3><?=$ph_set['title']?></h3>
                                <p><?=$ph_set['description'];?></p>
                                </a>
                            </li>
                          <?php endforeach; ?>
                        <?php $count++; ?>
                        <?php endforeach; ?>
                    </ul>
                </div>

Another Attempt

I have also tried calling the getPhotos function differently, instead of sending it without any parameters I sent it with parameters

$photos = $f->photosets_getPhotos($photoset_id, NULL, NULL, 1, NULL);

The above code stopped the showing all the photos from each photoset and started showing just the primary image, but it also stopped making the rest of the photos accesible to me.

Is there something I can do to make this work? I am totally out iof ideas.

Regards and thanks

  • 写回答

2条回答 默认 最新

  • douxin2003 2010-04-01 20:35
    关注

    What you'll probably want to do is starting by iterating through the whole array and grouping each album into a separate array first and making a special array for your album's main photo.

    Then you can easily iterate through the arrays to display each album and the code becomes much more maintainable.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 想用@vueuse 把项目动态改成深色主题,localStorge里面的vueuse-color-scheme一开始就给我改成了dark,不知道什么原因(相关搜索:背景颜色)
  • ¥20 OPENVPN连接问题
  • ¥15 flask实现搜索框访问数据库
  • ¥15 mrk3399刷完安卓11后投屏调试只能显示一个设备
  • ¥20 白日门传奇少一个启动区服和启动服务器的快捷键,东西都是全的 , 他们说套一个出来就行了 但我就是弄不好,谁看看,
  • ¥100 如何用js写一个游戏云存档
  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题