Support

Account

Home Forums General Issues Stop oEmbed in Basic WYSIWYG

Solving

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

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.