CMS Development

MattOnce
Contributor

How to exclude descriptive text for accessible images from the Blog wordcount

In my blog, I have started adding accessible descriptions (more detailed than alt tags) for images that convey important information.

The problem I have is that these descriptions are contributing to the total word count of the blog post, and therefore influencing the "Reading time" of the article.

 

Is there a way I could exclude these divs from the word count calculation, as they are making the posts seem longer than they are. Or alternatively, to reduce the wordcount total by x words?

Side note: I am aware of alt attributes and longdesc attributes, but these graphics require detailed explanations, and a longdesc attribute of that length would not be a great user experience.

0 Upvotes
2 Replies 2
MattOnce
Contributor

How to exclude descriptive text for accessible images from the Blog wordcount

Thanks for your response, webdew, would this affect the "x min read" amount displayed on the listing page?

0 Upvotes
webdew
Guide | Diamond Partner
Guide | Diamond Partner

How to exclude descriptive text for accessible images from the Blog wordcount

Hi @MattOnce ,

You need to add  |striptags|truncate(235, breakword=False, end='...') in your description field as shown in below example  to limit the text to display in each blog post, also you can increase or decrease the number value as per your requirements.

 

<div class="description-container">

       <p>{{content.post_list_content|striptags|truncate(235, breakword=False, end='...') }} </p> 

      </div>

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.