Title: Custom link for image?
Last modified: August 22, 2016

---

# Custom link for image?

 *  [GuardianAngel](https://wordpress.org/support/users/guardianangel/)
 * (@guardianangel)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-link-for-image/)
 * Hi!
 * I have begun playing with writing plugins and widgets and I have a problem…
 * I want to create a plugin the let’s me link an image with a URL but this URL 
   is generated using information I must fill in (ie or affiliate links and the 
   like).
 * I don’t know how to go about this…
 * essentially I want to do something that let’s me do something like this
 * `<a href="bla bla bla"><img src="test.png"></a>`
 * “bla bla bla” is generated from information I must fill in and, hopefully, I 
   would like to see be able the preview the image wrapped in this “link” in the
   visual editor…
 * What should I look at to be able to do something like this? I don’t know what’s
   available in WordPress programming wise to do this…
 * Thank you!
 * Nick

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/custom-link-for-image/#post-5304693)
 * If you want the image to appear in the visual editor, you might look at modifying
   the tinyMCE editor. Perhaps a toolbar button that is clicked when an image is
   selected that prompts for the link URL and wraps the image tag with the link.
   I’ve no experience modifying the editor but I know people do it all the time.
 * Another possibility would be to alter the WP Media Library using jQuery to insert
   an additional field when inserting an image. The real trick would be to alter
   what HTML gets placed in the editor when the “Insert into Post” button is clicked.
   The form goes to an admin page, maybe there’s a filter there you can hook to 
   achieve this. Worth further investigation?
 * Sorry I can’t give you a specific path to follow. Hopefully my half baked ideas
   at least get you started in a direction.
 *  Thread Starter [GuardianAngel](https://wordpress.org/support/users/guardianangel/)
 * (@guardianangel)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/custom-link-for-image/#post-5304815)
 * Hi bcworkz!
 * Sorry for the delayed reply…
 * That definitely gave me a good idea of how I could do it, thank you!
 * If I find any further information on this I will post back…
 * Once again thank you!
 * Nick

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom link for image?’ is closed to new replies.

## Tags

 * [links](https://wordpress.org/support/topic-tag/links/)
 * [programming](https://wordpress.org/support/topic-tag/programming/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [GuardianAngel](https://wordpress.org/support/users/guardianangel/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/custom-link-for-image/#post-5304815)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
