Any way to load an onclick locker event IMG in WordPress?
2018-04-02, 10:00 PM,
#1
Got a plugin to add the script to the head but need a solution for the center part.

If I add this with or without the code tags
Code:
<img onclick="og_load();"  style="cursor: pointer;" src="wp-content/uploads/2018/04/downloadnow1.png" alt="" width="455" height="116">

It loads the image in visual but when I check the code back in text it changed in
Code:
<code><img style="cursor: pointer;" src="/wp-content/uploads/2018/04/downloadnow1.png" alt="" width="455" height="116" /></code>

I'm going to assume I will need to add something to the functions.php but haven't found something yet.

Any idea?

Cheers.
Reply
Share This Thread :

2018-04-02, 11:35 PM, (This post was last modified: 2018-04-02, 11:37 PM by ⭐️ Borislav ⭐️.)
#2
Try adding link

Code:
<a onclick="og_load();"><img style="cursor: pointer;" src="wp-content/uploads/2018/04/downloadnow1.png" alt="" width="455" height="116">
</a>


I don't know why is deleteing onclick element...

If that doesn't work then add class to img element like:

Code:
<img class="locker" style="cursor: pointer;" src="wp-content/uploads/2018/04/downloadnow1.png" alt="" width="455" height="116">

And then in JavaScript:
Code:
$( ".locker" ).attr('onclick', "og_load();");
If that doesn't work either, then this should work!
Javascript:

$( ".locker" ).click( function() {
    og_load();
});
Latest Thanks - View all

Lone Wolf(2018-04-02 11:52 PM) 
Reply
2018-04-02, 11:56 PM, (This post was last modified: 2018-04-03, 12:44 AM by Lone Wolf.)
#3
(2018-04-02, 11:35 PM)⭐️ Borislav ⭐️ Wrote: Try adding link

Code:
<a onclick="og_load();"><img style="cursor: pointer;" src="wp-content/uploads/2018/04/downloadnow1.png" alt="" width="455" height="116">
</a>


I don't know why is deleteing onclick element...

If that doesn't work then add class to img element like:

Code:
<img class="locker" style="cursor: pointer;" src="wp-content/uploads/2018/04/downloadnow1.png" alt="" width="455" height="116">

And then in JavaScript:
Code:
$( ".locker" ).attr('onclick', "og_load();");
If that doesn't work either, then this should work!
Javascript:

$( ".locker" ).click( function() {
    og_load();
});
Thanks, I've been trying to find a solution for this for the past 2 hours and on the WP stackexchange they come with a lot of stuff I don't understand at all like:

Quote:Then perhaps this will help: sitepoint.com/wordpress-change-img-tag-html , which shows how to add a filter that will change the img tag. This post stackexchange.com/questions/81522/change-html-structure-of-all-img-tags-in-wordpress will get you started on how to use the DOM object to change all img tags to add the on-click event. It depends on when you want to add that onclick parameter to the img tag; on post 'save' or post 'view'. I'd personally use the DOM object, since it appears that you want to add that function for all img tags

Hopefully your resolution works better :)

Ugh, why such small thing so complicated  Sad I think it would benefit many people but can't get it to work.

This:
Code:
<img onclick="og_load();"  style="cursor: pointer;" src="wp-content/uploads/2018/04/downloadnow1.png" alt="" width="455" height="116">
turns into
Code:
<a><img style="cursor: pointer;" src="wp-content/uploads/2018/04/downloadnow1.png" alt="" width="455" height="116" />
</a>

This one sticks but it only shows a broken image in the visual editor and nothing on the live page
Code:
<img class="locker" style="cursor: pointer;" src="wp-content/uploads/2018/04/downloadnow1.png" alt="" width="455" height="116">

I hate it when I can't solve the puzzle cuz now I need to solve it Grin

Ok this is weird. When I replace the code in inspect element(F12) and add this:
Code:
<img onclick="og_load();"  style="cursor: pointer;" src="wp-content/uploads/2018/04/downloadnow1.png" alt="" width="455" height="116">

Then it does work.. wtf
Reply
2018-04-03, 01:34 AM, (This post was last modified: 2018-04-03, 01:46 AM by Lone Wolf.)
#4
Ugh, one step closer.

I managed to get it to work outside the inspector.

But for sure it's not perfect.

First off, I can't change to visual editor because it will strip the code directly and secondly the image is blurry as hell  Grumpy  

The code that seems to work (only in text editor) is:

Code:
<img src="" style="cursor: pointer;" onclick="og_load();" alt="" srcset="/wp-content/uploads/2018/04/downloadnow1-300x76.png 300w" sizes="(max-width: 455px) 100vw, 455px" width="455" height="116">
Sweet mother of God.

I think I fixed it all.

Still sucks I can't switch to visual editor but at least I got it working
Reply
2018-04-03, 02:02 AM,
#5
I thought your problem is that onclick don't work :))
It's easier to use Image URL
Reply
2018-04-03, 02:29 AM, (This post was last modified: 2018-04-03, 02:29 AM by Lone Wolf.)
#6
(2018-04-03, 02:02 AM)⭐️ Borislav ⭐️ Wrote: I thought your problem is that onclick don't work :))
It's easier to use Image URL

Well it didn't work.

The codes you gave all broke the image, I don't know why but you still helped me figure it out though because when I used your first HTML in the inspector it created it's own code which after some removing and changing some stuff I finally got it to work with the last code.

The only thing that keeps sucking is you can't change the editor to visual or it will strip the code again and removes the onclick.
Reply


Related Threads
Thread Author Replies Views Last Post
  Control tex/number who's already on img nabilox 0 245 2018-08-29, 05:18 PM
Last Post: nabilox
  OGads - How to change some words into bold in the file download locker? Lone Wolf 3 796 2018-08-04, 12:47 AM
Last Post: CreateAutomate
  How I load locker onclick image on the same page? Lone Wolf 4 670 2018-04-02, 09:43 PM
Last Post: Lone Wolf
  ANNOUNCEMENT How To Protect And Secure Your WordPress Websites For Free [HawkEye Guide] HawkEye 23 8,423 2018-03-11, 08:28 PM
Last Post: krypton_bleu
  Cpagrip locker template - Part 4 - Clash of Clans M!st3r XX 86 22,762 2017-12-28, 01:28 AM
Last Post: duquelf90





About Us | Contact Us | CPA Elites | Advertise | Stats

© 2013-2018 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top