Display page.summary without images in partials templates


#1

Hello,
on my website ( http://www.geobib.fr/blog/ ) I use grav with theme purity which is fine but I don’t really like that images are displayed as part of the truncated blog post like the green one just below :

According to template source it is page.summary that is used to display that part of text. I was looking for a filter that would remove the image before displaying the text, to have something that is more homogeneous amongst the posts that are listed.

Any idea on the best way to achieve that?


#2

one option is to create a new custom header property like:

title: My Title
summary: My summary **intro text** without an image

Then modify your Twig to use {{ page.header.summary|markdown }}

Or you could simply use the |striptags filter on thepage.summary() - https://twig.symfony.com/doc/2.x/filters/striptags.html to remove any images.


#3

Thanks @rhuk, I didn’t know the striptags filter, so {{ page.summary | striptags(“img”) }} perfectly does the trick!