Hi! On my event archive pages of film listings, it displays the (square) event thumbnail for each film. However I have a custom field containing a movie-poster image which I’d like to use instead.
In shortcode-event-list.php (in my child theme of course), I’m successfully using the following code to display that:
<?php
$image_ids = get_post_meta($post->ID, 'poster');
foreach ($image_ids as $image)
{
$myupload = get_post($image);
if (is_front_page()) {
echo wp_get_attachment_image( $image, 'homepage-thumb' );
} else {
echo wp_get_attachment_image( $image, 'poster-thumb' );
}
}
?>
And here’s an example of what that currently looks like:
https://staging-vjfforg.kinsta.cloud/festival-archives/2018-festival/
However, placing the same code in eo-loop-single-event.php (for display of tag archives) does not produce the same result. It shows the poster image, but at its original size, which varies tremendously and makes a mess of the layout. Here’s an example (I’ve added the above code to show what it produces, but left the original thumbnail code there as well):
https://staging-vjfforg.kinsta.cloud/events/tag/drama/page/2/
Can you advise why this is? I’ve tried so many things, and done so much digging into this, but still no luck.
Thanks so much!
Adam
Adam Abrams
Hi Adam,
Thumbnails are a WordPress feature, so there’s nothing the plug-in is doing here.
However, the image widths in the first page are being sett by the following CSS:
div.eo-event-cat-vjff img.attachment-poster-thumb, body.archive .archive-film-event img {
float: left;
border: 1px solid black;
display: block;
width: 185px;
margin-right: 15px;
}
and it appears to be done by the theme (or perhaps a customization you’ve made through the theme ): https://staging-vjfforg.kinsta.cloud/wp-content/et-cache/global/et-divi-customizer-global.min.css?ver=1642030696
If you add the following CSS to your theme for the event page, then it should style the image accordingly:
.eo-event-details img.attachment-poster-thumb {
float: left;
border: 1px solid black;
display: block;
width: 185px;
margin-right: 15px;
}
Stephen Harris
Thanks Stephen! In the end I finally realized that the solution was something entirely different – I was running a new theme that lacked the code from the previous one, which creates the custom thumbnail size being requested. Nothing to do with EO! Sorry to take up your time with this one!
Adam Abrams
No worries, glad you got this working
Stephen Harris