dosf40815 2017-02-16 08:11 采纳率: 100%
浏览 38

如何将WordPress Gallery缩略图更改为Sliding?

In my website user can upload photos to a page, But the thumbnails keep going down if it has lot of photos.

The layout of thumbnails that keeps going down and eat lot of spaces:

The layout of thumbnails that keeps going down and eat lot of spaces

Is there a way to change the thumbnails into sliding?

Here's the code

<?php if ( apply_filters( 'horizon_submission_listing_metabox_allowed', true, 'gallery', get_the_author_meta('ID') ) ): ?>
    <?php $gallery = get_post_meta( get_the_ID(), HORIZON_LISTING_PREFIX . 'gallery', true ); ?>
    <?php if ( ! empty( $gallery ) && is_array( $gallery ) ) : ?>
        <div class="listing-detail-section" id="listing-detail-section-gallery">
            <h2 class="page-header"><?php echo $section_title; ?></h2>

            <div class="listing-detail-gallery-wrapper" >
                <div class="listing-detail-gallery" >
                    <?php $index = 0; ?>
                    <?php foreach ( $gallery as $id => $src ) : ?>
                        <?php $img = wp_get_attachment_image_src( $id, 'large' ); ?>
                        <?php $src = $img[0]; ?>
                        <a href="<?php echo esc_url( $src ); ?>" rel="listing-gallery" data-item-id="<?php echo esc_attr( $index++ ); ?>">
                            <span class="item-image" data-background-image="<?php echo esc_url( $src ); ?>"></span><!-- /.item-image -->
                        </a>
                    <?php endforeach; ?>
                </div>


                <!-- /.listing-detail-gallery -->

                <div class="listing-detail-gallery-preview" data-count="<?php echo count( $gallery ) ?>">
                    <div class="listing-detail-gallery-preview-inner">
                        <?php $index = 0; ?>
                        <?php foreach ( $gallery as $id => $src ) : ?>
                            <div data-item-id="<?php echo esc_attr( $index++ ); ?>">
                                <?php $img = wp_get_attachment_image_src( $id, 'thumbnail' ); ?>
                                <?php $img_src = $img[0]; ?>
                                <img src="<?php echo $img_src; ?>" alt="">
                            </div>
                        <?php endforeach; ?>
                    </div><!-- /.listing-detail-gallery-preview-inner -->
                </div><!-- /.listing-detail-gallery-preview -->
            </div><!-- /.listing-detail-gallery-wrapper -->
        </div><!-- /.listing-detail-section -->
    <?php endif; ?>
<?php endif; ?>
  • 写回答

1条回答 默认 最新

  • douman6679 2017-02-16 08:22
    关注

    If you want to code this yourself, then you would need to apply some changes in CSS and add javascript code to create navigation for slider. The simplest way of doing that would be using for example jQuery, hiding all images and showing only one that is being currently viewed. You could all navigation buttons to coordinate showing/hiding the photos.

    More advanced solution which provides additional features would be to use a slider plugin, like this for example: https://wordpress.org/plugins/ultimate-responsive-image-slider/

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值