1

正如此处发布的https://www.concrete5.org/index.php?cID=751287我想使用“旧”方式从页面获取缩略图。

在我可以使用下面包含图像助手的代码之前。

<div class="image-link">
    <a <?php if ($target != '') { ?> target="<?php echo $target ?>" <?php } ?> href="<?php echo $url ?>">
        <?php
        $ts = $page->getBlocks('Thumbnail Image');
        if (is_object($ts[0])) {
            $tsb = $ts[0]->getInstance();
            $thumb = $tsb->getFileObject();
            if ($thumb) {
                $ih->outputThumbnail($thumb, 170, 80, $title);
            }
        }
        ?>
    </a>
</div>

从子页面的这一部分:

<div id="thumbnail">
    <?php
    if ($c->isEditMode()) {
        print '<br><br>';
        $a = new Area('Thumbnail Image');
        $a->display($c);
    }
    ?>
</div>

然而现在这一切都改变了,新系统使用页面属性作为缩略图。由于该站点已经设置了“旧”方式,因此我希望能够再次以相同的方式检索缩略图。

任何帮助将非常感激。

4

2 回答 2

1

我通过作曲家设置了“缩略图”页面属性,这就是我在页面模板中检索它的方式:

 <?php
     $thumbnail = $c->getAttribute('thumbnail');
     if($thumbnail) {
         $img = Core::make('html/image', array($thumbnail));
         $tag = $img->getTag();
         print $tag;
     }
 ?>
于 2015-06-30T18:09:44.713 回答
1

我挖出我的实验帽并修好了。

<div class="image-link">
                <a <?php if ($target != '') { ?> target="<?php echo $target ?>" <?php } ?> href="<?php echo $url ?>">
                    <?php
                    foreach ($blocks as $block) {
                        if ($block->getBlockTypeHandle() == "image" && $block->getAreaHandle() == "Thumbnail Image") {
                            if (is_object($block)) {
                                $tsb = $block->getInstance();
                                $thumb = $tsb->getFileObject();
                                if ($thumb) {
                                    $ih->outputThumbnail($thumb, 170, 80);
                                }
                            }
                        }
                    }
                    ?>
                </a>
            </div>
于 2015-06-30T20:23:54.873 回答