0

I want to be able to place an image inside a post within Sanity.io CMS and add an anchor tag around that image. This way when the user clicks on the image it will take them to a different page.

Whenever I click on the image, the link feature in the editor goes inactive.

I have tried searching for different plugins to resolve this issue, but I can't find any.

I am tempted to write my own custom block, but I feel that is a lot of effort for such a simple feature that should come right out of the box.

What would be an easier solution other than writing my own custom block?

Thanks in advance!

bsmith
  • 103
  • 3
  • 10

1 Answers1

0

I might add the URL as a field on the image. Then on the front end, you could check if the link exists and render out your code accordingly. That's how I've handled figcaptions: Wrap the image in figure and append the figcaption if that field exists, or just return the image if it doesn't.

Geoff Ball
  • 743
  • 3
  • 14