打印图像的宽度和高度php wordpress

时间:2020-11-10 14:28:44

标签: php html wordpress

我有以下代码,但是由于Lighthouse在没有显式宽度/高度的图像上给我错误,我尝试打印这些值,这些图像来自wp编辑器,所以我无法设置固定值 到目前为止,这是我的代码:

<div class="industry-recognition-content">
                <?php if (is_array($carousel_industry) || is_object($carousel_industry)): ?>
                    <div class="owl-carousel industry-recognition-logos">
                    <?php foreach($carousel_industry as $carousel_industry_items):
                    $image = $carousel_industry_items['logo'];
                    $image_size = 'medium'; // (thumbnail, medium, large, full or custom size)
                    $image_url = $image['sizes'][ $image_size ];
                    $link_industry = $carousel_industry_items['link_recognition'];
                    $new_image_dimen = image_resize_dimensions(isset($meta['width']), isset($meta['height']), $image_url[0], $image_url[1], $image_url[2], $image_url[3], $image_url[4], $image_url[5] );
                    ?>
                  
                        <div class="item">
                            <div class="logo">
                            <?php if($link_industry) : ?>
                                <a href="<?php echo $link_industry; ?>" target="_blank" rel="noopener noreferrer" class="clickable-link" aria-label="Brand URL">
                                <?php endif; ?>
                                    <img class="img-industry" width="<?php echo $new_image_dimen['width']; ?>" height="<?php echo $new_image_dimen['height']; ?>" data-src="<?php echo esc_url($image_url); ?>">
                                </a>
                            </div>
                        </div>
                    <?php endforeach; ?>
                    </div>
                <?php else : ?>
                    <div class="text-center">There are no items to show in this section</div>
                <?php endif; ?>     
                </div>

如您所见,我尝试添加新变量:new_image_dimen,但这并没有解决,在检查器中我得到了:

<img class="img-industry" width="" height="" data-src="somethingelse...;">

空的宽度和高度。有人知道如何为我的$ image_url打印这些值

0 个答案:

没有答案