dongyin8991 2017-05-16 11:34
浏览 42

如何为ACF库创建自己的自定义图像大小

I'm using Advanced Custom Fields to create an image gallery. At the moment I have the image size set to thumbnail I tried setting it to medium but it didn't work so I don't know if I'm missing something. But I would like to create my own image size anyway. So how would I do this? I was looking on the ACF site but it seems to have gone down.

<div class="container">
    <div class="row">
        <div class="col-md-12">
    <?php 

    $image_ids = get_field('gallery', false, false);

    $shortcode = '[gallery ids="' . implode(',', $image_ids) . '"]';

    echo do_shortcode( $shortcode );

    ?>

    <?php 

    $images = get_field('gallery');

    if( $images ): ?>

        <ul>
            <?php foreach( $images as $gallery_images ): ?>
                <li>
                    <a href="<?php echo $gallery_images['url']; ?>">
                         <img src="<?php echo $gallery_images['sizes']['thumb-nail']; ?>" alt="<?php echo $gallery_images['alt']; ?>" />
                    </a>
                    <p><?php echo $gallery_images['caption']; ?></p>
                </li>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>
        </div>
    </div>
</div>
  • 写回答

2条回答 默认 最新

  • dsfs504545 2017-05-16 12:17
    关注

    Generally, thumbnail is written 'thumbnail' and not thumb-nail. Maybe this is it ?

    Also, to create a custom image size in Wordpress, you need to add it to your functions.php file. Something like add_image_size( 'my-new-size', 220, 180, true );

    see https://developer.wordpress.org/reference/functions/add_image_size/

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用