如何在 cakephp 中的单个链接中两到三张图像


How to two or three image in a single link in cakephp?

我想要html格式的这段代码

<a href="images/p191-large.jpg" class="cloud-zoom-gallery" rel="useZoom: 'zoom11',  smallImage: 'images/p191.jpg' " title="Women's Crepe Printed Black"> 
    <img class="zoom-tiny-image" itemprop="image" src="images/p191.jpg" width="80" height="97" alt=""/>
</a>

我已经用 cakephp 编写了这段代码以获得上面的结果

<?php
echo $this->Html->link(
    $this->Html->image("p191.jpg", array(
        "alt" => "Pant Suit",
        "width" => "80",
        "height" => "97",
        'class' => 'zoom-tiny-image'
    )),
    array(
        'controller' => 'admins',
        'action' => '$this->Html->image(p191.jpg)'
    ),
    array(
        'class' => 'cloud-zoom-gallery',
        'title' => 'Women''s Crepe Printed Black',
        'escape' => false,
        'rel' => "useZoom: 'zoom11', smallImage: 'images/p191.jpg' "
    )
);
?>

但是将其作为输出

<a href="/stylishtailor1/admins/ ;image(p191.jpg)" class="cloud-zoom-gallery" title="Women's Crepe Printed Black" rel="useZoom: 'zoom11', smallImage: 'images/p191.jpg' ">
    <img src="/stylishtailor1/images/p191.jpg" alt="Pant Suit" width="80" height="97" class="zoom-tiny-image" />
</a>

我该怎么做,请回复???

这是最接近您想要的代码:

<?php
    echo $this->Html->link(
            $this->Html->image('/images/p191-large.jpg', array('alt' => 'Pant Suit', 'width' => '80', 'height' => '97', 'class' => 'zoom-tiny-image')),
            'images/p191-large.jpg',
            array('class' => 'cloud-zoom-gallery', 'title' => 'Women''s Crepe Printed Black', 'escape' => false, 'rel' => "useZoom: 'zoom11', smallImage: 'images/p191.jpg' ")
    );
?>

为了确保它正常工作,您必须检查两件事。图像路径(image()函数的第一个参数)应该具有完整路径,如果它不在webroot/img下,或者如果它在那里,可以省略起始/

要检查的第二件事是您的 url 位置(link()函数中的第二个参数)。您可以将其作为字符串或路由数组传递。在你的例子中,你传递了非常奇怪的数组。