如何在WordPress中使用任何jQuery缩放插件缩放附加的图像?

3

我需要关于我的WordPress主题的帮助。在我的文章中,我只使用附加的图片。因此,我制作了一个产品幻灯片,可以自动从此产品幻灯片中加载图像。 为了显示图片,我使用以下代码:

<?php echo wp_get_attachment_image($product_image->ID, array(350, 250)); ?>

但是这个功能也会创建一些包含图像的div元素。因此,我不能像jQuery缩放插件所需的那样仅向图像添加必要的类。有人能帮帮我吗?我只想使用一些这些缩放插件之一。
我没有很多声望,所以我不能在pastebin上发布链接。
这里是HTML+PHP。
<div id="slides" class="grid_5">

<div class="slides_container grid_5">
    <?php 
    $product_images = get_posts(
            array(
                'posts_per_page' => -1,
                'post_type' => 'attachment',
                'post_mime_type' => 'image',
                'post_parent' => $post->ID,
                'order' => 'ASC'
            )
        );

    foreach($product_images as $product_image) :?>
        <div>


            <center>
            <?php echo wp_get_attachment_image($product_image->ID, array(350, 250)); ?>
            </center>
        </div>
    <?php 
    endforeach;
    ?>
</div>
<br>
    <ul class="pagination grid_5">      
        <?php 
        reset($product_images);
        foreach($product_images as $product_image) :?>
            <li><a href="#"><?php echo wp_get_attachment_image($product_image->ID, array(50, 50)); ?></a></li>
        <?php 
        endforeach;
        ?>
    </ul>

And generated HTML: http://pastebin.com/EZByPvYm


你发送的链接很多,请问你具体使用了哪个 Zoom 插件?同时能否给我们提供生成的 HTML 代码? - Pit Digger
1个回答

0

wp_get_attachment_image() 有另外两个参数,第四个参数用于覆盖由wp_get_attachment_image()生成的HTML标签的属性,使用以下代码。

<?php echo wp_get_attachment_image($product_image->ID, array(350, 250), false, array('class' => 'YOUR-DESIRED-CLASSNAME')); ?>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接