Link Building with Auto Embed Code Script

Courtesy of: Paddy Moogan

The Ethical SEO team just got back from MozCon in the great city of Seattle, and we are excited to share some of the secrets we learned! In this post we’ll show you how to run a script (written by, Tom Anthony) which will cause embed code to be displayed whenever an image is right clicked. Paddy Moogan of Distilled shared this tip. Here, we’ll explain it so that, hopefully, anyone can implement it on their WordPress site!

Insert this code in your site’s header:

It should look something like this:

head code snip Link Building with Auto Embed Code Script








Now we need to add reference code to the actual image so that the embed code will be displayed whenever someone right clicks it.

If you have an image inserted in a post, you will see this in your HTML editor:

image html Link Building with Auto Embed Code Script










Enter this code in front of the image code. Now, your code should look like this:

Image HTML 2 Link Building with Auto Embed Code Script

Finally, you’ll need to add this code to your image source code, so it looks like this:

Image HTML 3 Link Building with Auto Embed Code Script









Please drop me a comment below if you are having any issues!

About the Author

Matt Green

+Matt is the Lead SEO Strategist at Ethical SEO Consulting. Connect with him on Twitter, G+, or drop by his blog.


  1. Ian Lockwood on August 2nd, 2012 2:42 pm

    Hi Matt, thanks for sharing this. I’ve just tried it and whilst it works, when there are multiple images in the page, it always opens the Embed text box where it first appears in the code, not next to the image that was right-clicked (although the URL in the embed code is correct for the image that was clicked).

    I guess you need to tie each image to a unique instance of the embed code above it, but I’m not sure how to do that – any ideas?

    1. Matt Green on August 2nd, 2012 2:54 pm

      Hi Ian – I actually haven’t tried it with multiple images. My assumption is that you’ll need to insert this code –, in front of each image to have the code box appear above the specific image. I’ll give it a whirl and let you know.

      1. Matt Green on August 2nd, 2012 2:58 pm

        Nope – my assumption was wrong. This may be a question for either Paddy or Tom Anthony, who wrote the script.

        1. Jordan on August 12th, 2012 10:12 pm

          What’s the purpose of this? This is supposed to help with sharing images through embeds as a method of link building? Anyone try this with any success yet?


          1. Matt Green on August 13th, 2012 3:07 pm

            That is correct. With the embed code automatically being displayed when the image is right clicked, the idea is that anyone who wants to use the image will be easily given the opportunity to do so using the embed code, which links back to the site where the image originated. Depending on the quality of the image and the amount of views it receives, this can be an effective link building tactic.

            1. Marisa on August 14th, 2012 1:01 pm

              But all you have to do is click on the image and it opens by itself and then you can save it!

              1. Matt Green on August 14th, 2012 2:51 pm

                Valid point :). The auto embed code does increase the likelihood that they will choose to embed the image and give you credit.

                1. Kevin on August 14th, 2012 3:47 pm

                  [reg: multiple images]
                  Or try it with jQuery and use selectors as $(this). to only influence the image you click on; not the others.

                  I like this nifty little thing, great for infograhics.

                  1. Matt Green on August 14th, 2012 4:36 pm

                    Thanks for the tip, Kevin!

                    1. Casey on August 14th, 2012 6:01 pm

                      But if they use your image you can just do a Google reverse image search and find them. Another link building tip :)

                      1. Lee on September 10th, 2012 6:15 pm

                        Hi, is there any way we can modify the image code so that its just an image, rather than linking to itself? This would solve the issue of people clicking the image, opening it on its own then copying it from there.

                        I did have a play about with it but the couple of things I tried, didn’t work.

                        1. Lee on September 10th, 2012 6:17 pm

                          Also, with Panda/Penguin and issues about more diverse link building, perhaps it would make sense to force the link back to the page the image was taken from? This would drive a lot of deep links back to your site, rather than sending them all to your homepage.


                          1. Matt Green on September 10th, 2012 7:27 pm

                            Great point. You can definitely adjust the code with a URL other than the home page. So, instead of a href=”” it would be a href=”

                            Regarding modifying the image so that it is not linked to directory where the image is stored, I’d have to defer to someone smarter than me to figure that out :)

                            Thanks for commenting!

                            1. j on September 11th, 2012 7:27 pm

                              Hi Matt,

                              Just wondering what happens if they try to copy an embeded image
                              from other place.
                              Is it possible and if so who gets the link ?



                              1. Matt Green on September 11th, 2012 8:16 pm

                                I think what you are saying is, what happens when a person embeds your image on site A, then someone else copies the image from site A onto site B. What would the image on site B then link to?

                                If this is what you mean, the answer is that, at this point the image may link to nothing. But, you could use Paddy’s Embed code inside embed code to get around that.

                                1. Ramesh Nair on September 14th, 2012 7:51 am

                                  Looks like a cool way to build link. Can one also include a keyword text along with the image – like how infographics get shared with a backlink?

                                  1. Matt Green on September 17th, 2012 10:35 pm

                                    Ramesh – yep. You just have to update your a href code to include anchor text. Be careful though – if a particular image attracts a bunch of links, you could end up with a Penguin-unfriendly link profile.

Leave a Comment