Home › Forums › General Issues › Stop oEmbed in Basic WYSIWYG
Does anyone have a good way to completely stop oEmbed like pasting in a YouTube URL from working in the Basic WYSIWYG fields?
I know I could filter it out on the front end, but I want to stop it from working at all on the backed so editor users don’t get the impression that’s something they can do.
We would want it to keep working for “Full” WYSIWYG fields, but the places we implement the “Basic” WYSIWYG we’re trying to just offer bold, italics, links and that’s all.
You can do this to heck the URL value. There are few different ways for the user to enter a URL so they all need to be covered
acf.addAction('load_field/key={the key of your oembed field}', function(field) {
$(field.$el).on("change", "input[type=text]", function(e){
let val = $(this).val();
// pass val to your validation method
});
$(field.$el).on("click", "input[type=text]", function(e){
let val = $(this).val();
// pass val to your validation method
})
$(field.$el).on("keyup", "input[type=text]", function(e){
let val = $(this).val();
// pass val to your validation method
})
})
That seems pretty heavy handed, and also has to be implemented on a field-by-field basis.
I was kind of hoping for something that would turn off that bit of javascript that converts a pasted URL into the embedded video before it ever happens, rather than letting it exist and then re-filtering to remove it on every keystroke or value change.
Was also hoping for a way to target all WYSIWYG Basic fields instead of individual field keys.
But maybe that’s just not possible.
You can target the field type:
acf.addAction('load_field/type=wysiwyg', function(field) {
///.. the code from above
})
the field variable being passed contains ‘toolbar’ ie field[‘toolbar’] – you need to check that for the name you gave the simple version (there is ‘basic’ built in) and then do your logic
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.