I'm trying to add links to images within a gallery so the image is clickable and links to an internal page or an external site. I found how to add a link on each image but it appear written on the images when I want it hidden so it looks more aesthetic. Is there a way to do this?
Hi @Clemsou! Thank you for your question. There is not currently a way to add links to images within a gallery, and there is a long-standing request for that in the core WordPress project at https://core.trac.wordpress.org/ticket/13429
I am going to close this issue a duplicate since there is already a feature request open for it. If you would like to add your voice to the exiting feature request, please add your vote and optionally post a little bit of detail about why you are trying to add links to gallery images and why it is important to you at https://wordpress.org/ideas/topic/custom-links-on-images-within-a-gallery
If you have future questions about how Gutenberg works, can you please post at https://wordpress.org/support/plugin/gutenberg to ask there first? It will help us to keep this area streamlined and support forums are the recommended first place to ask for help with how to use the editor or if a feature has already been requested or not. Thank you so much and thanks for testing Gutenberg and asking questions!
@joostmollerus you could do it by adding the images to a table or a columns block. If you need help or have questions about implementing something like that, please ask for help in the forums at https://wordpress.org/support/forum/how-to-and-troubleshooting/.
Although tedious, but simple (even for a non-developer), if you insert a gallery block and add gallery images and then set number of columns for block and set _link to:_ "Attachments", you can then go to the block and "edit in html" and just replace the _href=urls_ on each image with the link you want plus _target="_blank"_ if you want to open in new tab, etc. For a small gallery, it is not too bad but they do need to fix this.
I've had success wrapping the gallery's <figure>
tags in <a>
tags.
I found a plugin that will do this: https://wordpress.org/plugins/gallery-custom-links/ and I also discovered I had another premium plugin I was already using that does this. WP Media Folders which is an awesome plugin to create folders in the media library and you can delete the plugin and everything goes back to normal. https://www.joomunited.com/wordpress-products/wp-media-folder
One thing to keep in mind when assigning a link to the image is that anywhere you use that image it will contain the link which may be the behavior you want or maybe not. If not just create a second image with a different name.
Although tedious, but simple (even for a non-developer), if you insert a gallery block and add gallery images and then set number of columns for block and set _link to:_ "Attachments", you can then go to the block and "edit in html" and just replace the _href=urls_ on each image with the link you want plus _target="_blank"_ if you want to open in new tab, etc. For a small gallery, it is not too bad but they do need to fix this.
sasserc - this worked great - thank you!
Most helpful comment
Although tedious, but simple (even for a non-developer), if you insert a gallery block and add gallery images and then set number of columns for block and set _link to:_ "Attachments", you can then go to the block and "edit in html" and just replace the _href=urls_ on each image with the link you want plus _target="_blank"_ if you want to open in new tab, etc. For a small gallery, it is not too bad but they do need to fix this.