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 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。