Dawn Theme Slideshow Image Link without button but use button on others

Dawn Theme Slideshow Image Link without button but use button on others

kemmieg
Shopify Partner
42 2 9

I've added a link to my clients slideshow to make the image clickable but I've run into an issue with it and just need a little help with the if statement.

 

I only want images with the link to have the link but currently if I don't put a link in the second image, which is using the button. When I don't put the link in for the slide that has the button, the image is still clickable but it doesn't have the link so it just reloads the page. I'd like to have the if statement in there so that if the image doesn't have a link added, it will ignore that field and will allow the user to click the button instead.

 

I've added the link snippet found here https://websensepro.com/blog/how-to-make-slideshow-clickable-in-shopify-dawn-theme/ and it works great but want to be able to hide the link if empty.

 

I know this is probably something pretty simple but for some reason I'm having trouble remembering how this is achieved in Shopify themes.

 

Reply 1 (1)

01tranali
Shopify Partner
50 3 5

Hi @kemmieg ,

 

Modify your slideshow snippet by wrapping the image in a conditional check for the link:

{% if section.settings.image_link != blank %}
<a href="{{ section.settings.image_link }}">
{% endif %}
<img src="{{ section.settings.image | img_url: 'master' }}" alt="{{ section.settings.image.alt }}">
{% if section.settings.image_link != blank %}
</a>
{% endif %}

 

Best,
T