Home › Forums › Calendar Products › Events Calendar PRO › Show Excerpt With Thumbnail in Event List View
- This topic has 14 replies, 3 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
January 14, 2013 at 7:56 am #30747
Jordan Polon
ParticipantHello-
I wanted to limit the characters shown in the event list, and I followed the instructions found here: https://theeventscalendar.com/support/forums/topic/list-php-to-show-excerpt-instead-of-full-event-post/
It worked perfectly, except it also removed the image thumbnails. Is there a way to limit the number of characters shown and still have the image?
January 14, 2013 at 8:28 am #30754Barry
MemberYou can certainly limit the number of words. Where this piece of code is used (in Mike’s example):
TribeEvents::truncate($post->post_excerpt)You can add an extra parameter to specify how many words ought to be used (else it defaults to 44):
TribeEvents::truncate($post->post_excerpt, 100)This tutorial explains how to add thumbnails to the next event widget. In essence though you should be able to borrow the Add Thumbnail Code from the start of that tutorial and work it into your custom list template.
January 14, 2013 at 8:45 am #30765Jordan Polon
ParticipantThanks for the quick response. I’m wonderng if you could tell me how to change the original php:
to truncate the post. The images displayed perfectly then. Is there something in between what’s above and what’s down here:
post_excerpt) : TribeEvents::truncate(get_the_content(), 30); ?> that will leave the images as they were?January 14, 2013 at 8:54 am #30769Jordan Polon
ParticipantThe original was:
The new is:
post_excerpt) : TribeEvents::truncate(get_the_content(), 30); ?>Sorry that didn’t show up before.
January 14, 2013 at 8:55 am #30770Jordan Polon
ParticipantTrying again with the original:
The new is:
post_excerpt) : TribeEvents::truncate(get_the_content(), 30); ?>Sorry that didn\’t show up before.
January 14, 2013 at 9:01 am #30772Barry
MemberHi Tara – you will need to use Pastebin or Gist (or a similar service) to share code in the forum, I’m afraid.
January 14, 2013 at 9:26 am #30780Jordan Polon
ParticipantJust realized that. Sigh.
January 14, 2013 at 9:32 am #30783Barry
MemberYep, sorry! We’re aware it’s a pain and some changes are in the works, but for the time being using Pastebin/Gist etc is the best workaround we can suggest :-/
January 14, 2013 at 9:56 am #30786Jordan Polon
ParticipantSo this showed the images in the event list, perfectly: http://pastebin.com/r5mjvgny
This is what I am using now: http://pastebin.com/V1RcbQvG
Is there something I could have done to just truncate the text, instead of doing what I did? The other option changes the styling, etc.January 15, 2013 at 6:14 am #30840Barry
MemberOh … I think I see now: in your scenario, are the images actually inside the content, rather than being designated post featured images?
January 15, 2013 at 6:17 am #30841Jordan Polon
ParticipantYes! That’s exactly it. (And the new WP media uploader is a pain!) Is there a workaround for just truncation of the text?
January 15, 2013 at 6:45 am #30849Barry
MemberWell, I’m not sure there is an easy way to automate this and still retain images in this fashion … unless you switch to using post thumbs (featured images) and work in code from the tutorial I linked to in my first reply.
The problem is, what looks like an image in the visual post editor is actually a bit of code like this:
<img src="http://website.com/wp-content/uploads/2013/01/my-aunt-bessy-and-her-stuffed-giraffe_1024x800.png" alt="Old photo of my Aunt Bessy holding her stuffed giraffe, which Great Uncle Sim won in the 1908 Summer Fete during the Klondyke Gold Rush" title="What a lovely giraffe toy!" />So if we limit the number of characters, clearly we don’t want to include the many characters that make up an image tag. A further complication is, what if you have emboldened text, italicized it, both of those and/or you have applied other effects? That also means further tags are going to be present in the text.
The parser would have to be sufficiently complex to deal with all of that and be able to neatly close off each HTML element in the correct order, especially if the cut off point was half way through a set of nested elements.
For that reason, the truncate() method simply dispenses of tags and so I’d recommend the use of post thumbs instead of trying to display a shortened piece of content that retains images in the post.
Hope that makes sense!
January 16, 2013 at 8:56 pm #31003Jordan Polon
ParticipantThat does. Thanks very much.
January 17, 2013 at 10:13 am #31037Barry
MemberNo problem 🙂
July 7, 2015 at 6:26 am #978435Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Show Excerpt With Thumbnail in Event List View’ is closed to new replies.
