Home › Forums › Calendar Products › Events Calendar PRO › Validate Presence & Aspect Ratio of Featured Image?
- This topic has 3 replies, 2 voices, and was last updated 10 years, 6 months ago by
George.
-
AuthorPosts
-
October 23, 2015 at 8:51 am #1017335
Josh
ParticipantHello,
I am trying to achieve a look in photo view where each tile is the same size. It seem that I can fix most of the variation by truncating the description and adding a little extra space to account for variable date and title length. However, the featured image is problematic. If the admin does not provide a featured image or the featured image has a different aspect ratio from the others (especially if it is very tall), it changes the size of the whole tile. Therefore, I have a few questions:
- Is it possible to validate the presence of a featured image – maybe a before-save hook/filter? (i.e. Can I show an error message to the admin if they try to save or update an event without a featured image?)
- Is it possible to validate the aspect ratio of a featured image before save?
- Do you have any other suggestions for ensuring that the tiles in photo view are all the same height?
Thanks!
October 23, 2015 at 10:03 am #1017371George
ParticipantHey @josh,
Unfortunately these are mostly customization questions, which we cannot help with, or are related to Featured Images within WordPress which is not anything that The Events Calendar affects or manipulates. So there is little insight or help we can provide here 🙁 I will try to address some of your questions though regardless!
Is it possible to validate the presence of a featured image – maybe a before-save hook/filter? (i.e. Can I show an error message to the admin if they try to save or update an event without a featured image?)
This is possible with custom code, but there are also plugins out there that make Featured Images required and such. Here’s just one example of such a plugin → https://wordpress.org/plugins/require-featured-image/ Explore wordpress.org/plugins for similar ones; using a plugin for this will be a huge time-saver!
Is it possible to validate the aspect ratio of a featured image before save?
This is something that The Events Calendar has no bearing on, so I don’t know much what to say here – however, just like above I would recommend searching for media-library or featured-image related plugins out there that enable the sorts of controls you are looking for. You might be surprised what you find out there!
One thing that might help here is to use add_image_size() on your site to make a new thumbnail size on your site – upon image upload, then, the image will be cropped to this size and thus if you use this size in your templates it will be more uniform than not using it. Learn more about this function here → https://developer.wordpress.org/reference/functions/add_image_size/
Do you have any other suggestions for ensuring that the tiles in photo view are all the same height?
I would recommend the add_image_size() function I recommended above; then, use this image size in The Events Calendar’s Photo View. To do that, head into your Events Calendar Pro plugin files and navigate to this file:
src/views/pro/photo/single-event.php
Look for this line of code:
<?php echo tribe_event_featured_image( null, 'medium' ); ?>Notice that string that says ‘medium’ ? Well, if you use the add_image_size() function I mentioned above to make an image size named ‘josh-example’, then replace this string ‘medium’ with ‘josh-example’ – then, the photo view’s photos will all be this ‘josh-example’ size.
I hope there’s enough here to get you started with your customizations!
— George
October 23, 2015 at 1:25 pm #1017434Josh
ParticipantAh, ok, I didn’t realize Featured Image was a wordpress feature and not an ECP feature. That info is enough to get me started.
Thanks!
October 26, 2015 at 11:27 am #1018047George
ParticipantNo worries @Josh! Thanks for the update and such – I’ll close up this thread for now but open a new one anytime other questions/comments/concerns arise 😀
Cheers,
George -
AuthorPosts
- The topic ‘Validate Presence & Aspect Ratio of Featured Image?’ is closed to new replies.
