YouTube Detection
Smart Local Youtube finds YouTube embeds using 7 built-in regex patterns, applied to the finished page HTML during Joomla's onAfterRender event, on front-end HTML pages. You can add one more pattern of your own in the Expert Mode tab.
The 7 Built-in Patterns
| # | Pattern | What it catches |
|---|---|---|
| 1 | Standard iframe | <iframe src="/...youtube.com/embed/VIDEO_ID..."> — the default embed code from YouTube's Share dialog |
| 2 | Privacy-enhanced iframe | <iframe src="/...youtube-nocookie.com/embed/..."> — YouTube's "privacy-enhanced mode" embed |
| 3 | IFrame API script | <script src="/...youtube.com/iframe_api"> — the YouTube Player JavaScript API |
| 4 | Entity-encoded iframe | <iframe ... youtube.com ... ></iframe> — iframes that page builders store HTML-entity-encoded and decode in the browser |
| 5 | Smart Slider 3 | The n2_ss_video_player__cover element of a Smart Slider 3 YouTube video layer |
| 6 | YouTube Gallery | <script> blocks of the YouTube Gallery Joomla component (its player iframes are caught by patterns 1 and 2) |
| 7 | oEmbed link | <a href="/...youtu.be/..." class="oembed"> — TinyMCE / JCE oEmbed anchor tags |
Each match is removed from the output before the page is sent to the browser. In the overlay positions a single consent box is added; in Inline (replace video) each video is replaced individually with a placeholder.
Two kinds of matches are handled specially in inline mode:
- Scripts that show nothing by themselves (the IFrame API script and the YouTube Gallery script) are removed without a placeholder, so no empty box appears in the page or in the
<head>. - Smart Slider 3 is matched by its opening tag only, so the slider's nested markup is never cut in half.
Why So Many Patterns?
YouTube embeds reach a Joomla page through many routes — the editor's oEmbed feature, a slider extension, a gallery component, or a page builder that re-encodes HTML. A consent manager that only strips the standard iframe leaves the rest contacting Google. Covering these forms means the common ways a video lands on your page are handled out of the box.
Standard vs Privacy-Enhanced Embeds
YouTube offers a "privacy-enhanced" embed served from youtube-nocookie.com. It still contacts Google and still requires consent under GDPR — it simply delays some cookie-setting. The plugin detects both the standard and nocookie variants, so switching your embeds to nocookie does not bypass the consent requirement.
Per-Match Video ID Extraction
In inline mode the plugin reads the YouTube video ID from each match (from /embed/, youtu.be/ or data-youtube-code). The ID drives the per-video poster lookup and the optional YouTube-thumbnail fetch. See Placeholder Images.
What Is Not Detected
- Players built entirely by JavaScript after the page has loaded, when their markup is not in the server HTML
- Plain links to
youtube.com/watchoryoutube.com/shortspages (these are ordinary links and load nothing until clicked) - oEmbed anchors whose
classattribute comes beforehref
For these, add a Custom Regex Pattern that targets the loader or the markup.
Custom Regex Pattern
When a template or extension uses markup none of the 7 patterns match, add your own regex in the Expert Mode tab. It runs alongside the built-ins. See Expert Mode for syntax rules and a step-by-step workflow.
Debug Mode
Enable Debug Mode in the Expert Mode tab and log in on the front end as a Super User to see exactly which patterns matched on the current page and how many times — the fastest way to confirm coverage or diagnose a missed embed.