0

Even if users disable the popular Lazy Load for Videos plugin and the frontend correctly resets videos so that videos are no longer lazy-loaded, the Gutenberg block does not get reset. Below screenshot shows how the iframe still includes the HTML of the deactivated plugin:

enter image description here

I cleared my browser cache and cookies, I ensured the oembed metadata caches are emptied, and I tried to clear more caches using commands from How can I clear oEmbed caches for YouTube on posts as they are loaded.

How can I ensure that the old HTML disappears in favor of the default Youtube embed behavior?

1 Answer 1

0

The WordPress (Gutenberg) block editor requests data from an oembed proxy endpoint, and that endpoint retrieves data using the Transients API. It seems that clearing all oembed caches doesn't also clear oembed transient caches.

The following database query to clear your oembed caches from the postmeta table is NOT sufficient:

global $wpdb;
$meta_key_1 = "|_oembed|_%%";
$meta_key_2 = "|_oembed|_time|_%%";
$wpdb->query(
    $query = $wpdb->prepare( 
        "DELETE FROM `".$wpdb->postmeta."`
            WHERE `meta_key` LIKE %s ESCAPE '|'
            OR `meta_key` LIKE %s ESCAPE '|'",
        $meta_key_1,
        $meta_key_2
    )
);

You'll also need to clear the transient caches from the options table, like so:

$option_name_1 = "|_transient|_oembed|_%%";
$option_name_2 = "|_transient|_timeout|_oembed|_%%";
$wpdb->query(
    $query = $wpdb->prepare( 
        "DELETE FROM `".$wpdb->options."`
            WHERE `option_name` LIKE %s ESCAPE '|'
            OR `option_name` LIKE %s ESCAPE '|'",
        $option_name_1,
        $option_name_2
    )
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.