Last active
May 29, 2026 15:55
-
-
Save SteveJonesDev/be53c109c62fcd2f57b8566800a40339 to your computer and use it in GitHub Desktop.
WordPress Oxygen page builder: Move title attribute to iframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| function fixOxygenVideoTitles() { | |
| document.querySelectorAll( '.ct-video[title]' ).forEach( function ( wrapper ) { | |
| const iframe = wrapper.querySelector( 'iframe' ); | |
| const title = wrapper.getAttribute( 'title' ); | |
| if ( iframe && title && ! iframe.getAttribute( 'title' ) ) { | |
| iframe.setAttribute( 'title', title ); | |
| wrapper.removeAttribute( 'title' ); | |
| } | |
| } ); | |
| } | |
| function init() { | |
| fixOxygenVideoTitles(); | |
| const observer = new MutationObserver( fixOxygenVideoTitles ); | |
| observer.observe( document.body, { | |
| childList: true, | |
| subtree: true, | |
| } ); | |
| } | |
| if ( document.readyState === 'loading' ) { | |
| document.addEventListener( 'DOMContentLoaded', init ); | |
| } else { | |
| init(); | |
| } | |
| window.addEventListener( 'load', fixOxygenVideoTitles ); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment