Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Link blog image to page URL in Antimatter Blog Theme

Started by Muut Archive 12 years ago · 2 replies · 505 views
12 years ago

Hi Guys,

I know it's mostly developer types in here but thought this might be useful to someone who's not a coder (kind of like me :-). I'm using the Antimatter theme and wanted to link the blog image at the top of the posts to the post URL.

First you need to set up your custom theme using theme inheritance.

Then when you have that set up you need to edit your user/themes/mytheme/templates/partials/blog_item.html.twig file.

Where you see the code

TWIG
   {% endif %}
        {% if big_header %}
            {{ page.media.images|first.cropResize(900,600).html }}
        {% else %}
            {{ page.media.images|first.cropZoom(900,300).html }}
        {% endif %}

You need to change it to

TWIG
   {% endif %}
        <a href="{{ page.url }}">
        {% if big_header %} 
            {{ page.media.images|first.cropResize(900,600).html }}
        {% else %}
            {{ page.media.images|first.cropZoom(900,300).html }}
            </a>
        {% endif %}

Now the images that show at the top of your blog posts should link to the actual post.

Admins and developers if there's a better way of doing this please let me know :-)

12 years ago

You need to put your last </a> below the {% endif %} or you will have issues when using big_header. This is because you have the opening tag above the if statement, so the closing tag should be below it.

12 years ago

Ahhh.....thanks for that rhukster. Have made this edit.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 672 1 week ago
Archive · by Deleted User, 9 years ago
0 3043 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5336 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago