Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Link blog image to page URL in Antimatter Blog Theme

Started by Muut Archive 11 years ago · 2 replies · 271 views
11 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 :-)

11 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.

11 years ago

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

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1329 9 years ago
Archive · by Muut Archive, 9 years ago
2 922 9 years ago
Archive · by Muut Archive, 9 years ago
2 4051 9 years ago
Archive · by Muut Archive, 9 years ago
1 2930 9 years ago
Archive · by Muut Archive, 9 years ago
3 1108 9 years ago