【问题标题】:How to zoom attached images with any jQuery Zoom Plugin in WP?如何使用 WP 中的任何 jQuery Zoom 插件缩放附加图像?
【发布时间】:2012-10-03 15:38:11
【问题描述】:

我的 WordPress 主题需要帮助。在我的文章中,我只使用附加的图像。所以我制作了一个产品滑块,可以自动加载附加到这个产品滑块的图像。 要显示我使用的图像:

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

但是这个函数也创建了一些显示图像的 div 元素。所以我不能像 jQuery 缩放插件所需要的那样向图像添加一个需要的类。有谁能够帮我?我只是想使用一些these zoom plugins

我没有太多的声誉,所以我不能在 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>

并生成 HTML:http://pastebin.com/EZByPvYm

【问题讨论】:

  • 您发送的链接有很多。您使用的是哪个特定的缩放插件?也可以给我们生成的 HTML 代码吗?

标签: php jquery wordpress


【解决方案1】:

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')); ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-01
    • 1970-01-01
    相关资源
    最近更新 更多