英文:
How to add the gallery images to property-print.php on Essential real Estate wordpress plugin
问题
我一直在尝试在生成的PDF上显示画廊中的图像(不仅仅是属性缩略图),但我无法做到。
我最后尝试的是这样的:
$property_gallery = ere_get_property_gallery_images();
if ( $property_gallery ) {
echo '<div class="property-gallery">';
foreach ( $property_gallery as $image ) {
echo '<img src="' . $image . '" />';
}
echo '</div>';
}
但它只返回一个空白的PDF。
英文:
I have been trying to display the images of the gallery (not only the property thumbnail) on the pdf generated (on property-print.php template) on the print icon but i can't manage to do it.
last thing i tried was this:
<?php
$property_gallery = ere_get_property_gallery_images();
if ( $property_gallery ) {
echo '<div class="property-gallery">';
foreach ( $property_gallery as $image ) {
echo '<img src="' . $image . '" />';
}
echo '</div>';
}
?>
But it just returns a blank pdf.
答案1
得分: 0
它返回空白的PDF,因为它发现了致命错误
请尝试以下代码:
```php
$property_gallery = get_post_meta($property_id, ERE_METABOX_PREFIX . 'property_images', true);
if ($property_gallery) :
$property_gallery = explode('|', $property_gallery);
?>
<div class="property-gallery">
<?php
$gallery_id = 'ere_gallery-' . rand();
foreach ($property_gallery as $image) :
$image_src = ere_image_resize_id($image, 1920, 1080, true);
if (!empty($image_src)) {
?>
<img src="<?php echo esc_url($image_src) ?>" width="1160" height="500">
<?php } ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
英文:
It is return blank pdf because it found fatal error
Try the following code:
<?php
$property_gallery = get_post_meta($property_id, ERE_METABOX_PREFIX . 'property_images', true);
if ($property_gallery) :
$property_gallery = explode('|', $property_gallery);
?>
<div class="property-gallery">
<?php
$gallery_id = 'ere_gallery-' . rand();
foreach ($property_gallery as $image) :
$image_src = ere_image_resize_id($image, 1920, 1080, true);
if (!empty($image_src)) {
?>
<img src="<?php echo esc_url($image_src) ?>" width="1160" height="500">
<?php } ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论