phpflickr api

发布于 2024-08-27 13:14:09 字数 1906 浏览 2 评论 0原文

概述
我正在尝试使用 Flickr 的 api 和 phpflickr 库将照片提要添加到我的网站上。我可以成功地将照片集放到我的网站上,但它显示了每个照片集中的所有照片,我希望实现的是显示每个照片集中的主要照片,然后如果用户单击该图像,它将显示灯箱/阴影箱中的完整照片集。

我的代码

<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>

另一次尝试

我还尝试以不同的方式调用 getPhotos 函数,而不是不带任何参数发送它,而是使用参数发送它

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

上面的代码停止显示来自的所有照片每张照片集并开始只显示主图像,但它也停止让我可以访问其余的照片。

我可以做些什么来让这项工作成功吗?我完全没有想法。

问候和感谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心清如水 2024-09-03 13:14:09

我想出了这个解决方案,我想我会发布它以防其他人遇到这个问题,

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

I came up with this soltion, thought I would post it in case anyone else hits this problem,

<?php $count = 1; ?>
<?php foreach ($photosets['photoset'] as $ph_set): ?>
<?php $parentID = $ph_set['parent']; ?>
<li>
     <?php $photoset_id = $ph_set['id'];
     $photos = $f->photosets_getPhotos($photoset_id);
         foreach ($photos['photoset']['photo'] as $photo): ?>
             <?php if($parentID == $ph_set['parent']): ?>
             <a rel="lightbox[album<?=$count;?>]" href="<?= $f->buildPhotoURL($photo, 'medium') ?>" title="<?= $photo['title'] ?>">
         <?php endif;?>
         <img src="<?= $f->buildPhotoURL($photo, 'rectangle') ?>" alt="<?= $photo['title'] ?>" width="210" height="160" title="<?= $photo['title'] ?>" />
             <h3><?=$ph_set['title']?></h3>
         <?php if($ph_set['description'] != null) :?>
             <p><?=$ph_set['description'];?></p>
         <?php endif; ?>
         <?php if($parentID == $ph_set['parent']): ?>
                 </a>
        <?php endif;?>
<?php endforeach; ?>
</li>
<?php $count++; ?>
等风也等你 2024-09-03 13:14:09

您可能想要做的就是首先迭代整个数组,首先将每个相册分组到一个单独的数组中,然后为相册的主照片创建一个特殊的数组。

然后,您可以轻松地遍历数组来显示每个专辑,并且代码变得更易于维护。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文