Add link to image Dawn Theme

Solved

Add link to image Dawn Theme

Ulysse1234
Excursionist
42 0 17

Hi,

I've got some issues, I’d like to add a link on the image on the left so it could redirect to another page but I don't know how to do it.

 

Somebody knows how to do it please? 

 

Website: https://rvmmpz-4s.myshopify.com

 

1112.png

Accepted Solution (1)
devcoders
Shopify Partner
1595 189 488

This is an accepted solution.

Hello @Ulysse1234 
Please check.

devcoders_0-1738687263280.png

 

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com
WhatsApp No: +91 8516919310 If my assistance was helpful, please consider liking and accepting the solution. Thank you!

View solution in original post

Replies 4 (4)

htmlBurger
Shopify Partner
87 8 21
Hello,

To do this, a new setting for the image link should be added to the section. However, for this, you'll need to hire a developer as it is not a very straightforward job.

As a workaround, and only if you use this section once, you can use the following approach.

Go to Online store -> Themes -> Edit code. Then open this file collapsible-content.liquid.

Locate this code:
 

 

 

<div
  class="collapsible-content__media collapsible-content__media--{{ section.settings.image_ratio }} media global-media-settings gradient"
  {% if section.settings.image_ratio == 'adapt' %}
    style="padding-bottom: {{ 1 | divided_by: section.settings.image.aspect_ratio | times: 100 }}%;"
  {% endif %}
>
  {%- liquid
    assign padding_multiplier = 1
    if section.settings.layout == 'section'
      assign padding_multiplier = 2
    endif
    assign desktop_tablet_padding = 100 | times: padding_multiplier | append: 'px'
    assign mobile_padding = 30 | times: padding_multiplier | append: 'px'
  -%}
  {%- capture sizes -%}
    (min-width: {{ settings.page_width }}px) calc(({{ settings.page_width }}px - {{ desktop_tablet_padding }}) / 2),
    (min-width: 750px) calc((100vw - {{ desktop_tablet_padding }}) / 2),
    calc(100vw - {{ mobile_padding }})
  {%- endcapture -%}
  {{
    section.settings.image
    | image_url: width: 3200
    | image_tag:
      sizes: sizes,
      widths: '50, 75, 100, 150, 200, 300, 400, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3200'
  }}
</div>

 

 

 

and replace it with:

 

 

<a href="YOUR LINK GOES HERE">
  <div
    class="collapsible-content__media collapsible-content__media--{{ section.settings.image_ratio }} media global-media-settings gradient"
    {% if section.settings.image_ratio == 'adapt' %}
      style="padding-bottom: {{ 1 | divided_by: section.settings.image.aspect_ratio | times: 100 }}%;"
    {% endif %}
  >
    {%- liquid
      assign padding_multiplier = 1
      if section.settings.layout == 'section'
        assign padding_multiplier = 2
      endif
      assign desktop_tablet_padding = 100 | times: padding_multiplier | append: 'px'
      assign mobile_padding = 30 | times: padding_multiplier | append: 'px'
    -%}
    {%- capture sizes -%}
      (min-width: {{ settings.page_width }}px) calc(({{ settings.page_width }}px - {{ desktop_tablet_padding }}) / 2),
      (min-width: 750px) calc((100vw - {{ desktop_tablet_padding }}) / 2),
      calc(100vw - {{ mobile_padding }})
    {%- endcapture -%}
    {{
      section.settings.image
      | image_url: width: 3200
      | image_tag:
        sizes: sizes,
        widths: '50, 75, 100, 150, 200, 300, 400, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3200'
    }}
  </div>
</a>

 

 

 

Change `YOUR LINK GOES HERE` with your actual link. If you want the link to be opened in a new tab, use this: `<a href="YOUR LINK GOES HERE" target="_blank">`

 

----

 

Please note, that the approach above will hardcode this link to all instances of this section. This means that if you have 3 different Collapsible content sections on 3 different pages, all of them will share the same link (as the link is hardcoded in the code). I hope this makes sense.

 

Let me know if this was helpful



Found this helpful? Like and accept as solution to help others too!
htmlBurger – Founded in 2007, Shopify experts for 10+ years.
Custom themes, UI/UX design, ongoing maintenance & support.
Let's talk: ecom@htmlburger.com
Ulysse1234
Excursionist
42 0 17

Thanks for the help but the thing is that I want to add different link on the different section that's why It's a bit complex 

devcoders
Shopify Partner
1595 189 488

This is an accepted solution.

Hello @Ulysse1234 
Please check.

devcoders_0-1738687263280.png

 

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com
WhatsApp No: +91 8516919310 If my assistance was helpful, please consider liking and accepting the solution. Thank you!
Ulysse1234
Excursionist
42 0 17

Thanks a lot