Be sure to checkout our newest add-on Speedy!

EE compatibility updates:

  • Publisher is EE5 compatible, but it does not currently support the Fluid field. licenses:

  • If you purchased an add-on from, be sure to visit to add the license to your account here on

Ticket: Iframe redirect issues

Status Resolved
Add-on / Version Publisher 2.10.6
EE Version 4.3.7

Hop Studios

Feb 04, 2019

Hello Brian,

I observed 2 anomalies while checking on the staging site.

1. When there is a scripts included with plain url (i.e. without any language prefix, chrome takes it to the script page when a switch_language_url is clicked
2. When I put an iframe without the language prefix but view it in different language, I get redirect too many times error on chrome and page redirection on safari

The first one is not a big deal because I can wrap all JS in minimee and the path redirection doesn’t happen. But the second one is kind of troublesome.

I have Show content fallback (FE) turned on and Persistent Entries turned on.

Testing page:


BoldMinded (Brian)

Feb 04, 2019

A page like (which I assume is loaded through an EE template?) looks like a normal http/page request to everything, including Publisher, so it doesn’t know that it is supposed to be a JS request and not perform any redirects. I’d suggest either use the hidden template prefix (. or _) or don’t serve JS files through EE templates (I’d recommend this approach).

As for the iframe issue, have you tried it without embedding the iframe code in a wysiwyg field? It’s probably struggling to find out what language to set it to.


BoldMinded (Brian)

Feb 04, 2019

Try changing the iframe source to src=”{site_url}/broadcast/simple_player”


Hop Studios

Feb 04, 2019

I moved the html out of the WYSWIG and pasted it directly in the template.

It loads now but it now redirects you to the iframe src.

However, if you type in the url specifically it works.


Hop Studios

Feb 04, 2019

I don’t know if it’s useful information but on EE2 with version 1.7.5 the embed just works.


BoldMinded (Brian)

Feb 04, 2019

I would find a way to get the prefix in there the first time the iframe source is loaded. There isn’t a reliable, and more importantly a non-specific to your site way, for me to add code to Publisher to determine if the current request is inside an iframe.


Hop Studios

Feb 04, 2019

I tried your suggestions and they didn’t work when the switch language action is triggered. I dug deeper and found that the iframe url is getting recorded in the EE Tracker and being added to the segments to build to the url [Service/Url/Url.php @ line 380]. So when the switch language url is clicked, it goes to the iframe.

I’m assuming this happens to all sites with iframe. Can you provide any directions about how I can resolve this?


BoldMinded (Brian)

Feb 04, 2019

Did you try setting the src to src=”{site_url}/broadcast/simple_player”? Your last couple of comments weren’t very clear on if you did that part specifically.


Hop Studios

Feb 05, 2019

Yes I did.

So what happened was that when you go to which has the iframe src=”{site_url}/broadcast/simple_player”, clicking any one of the Switch Language Urls will take you to the src url like

This is because the set_language function calls the session service’s changeLanguage function which calls the url service’s addPrefixToUrl function. When the segment is built with getCurrentSegments, the iframe src is included.


Hop Studios

Feb 06, 2019

Hello Brian,

I’ve tested on a fresh install and confirm that this is happening on sites that have the following settings:
Enable URL translations off
Add URL Prefix on
Add URL prefix to the homepage on
Hide the prefix for default language on

Create a template includes/iframe
Create a template testing/iframe and add the publisher switch urls with <iframe src=”/includes/iframe”></iframe>
Go to
Click a switch language url link and see how it takes you to rather than

Here are the modifications that I made to make the site not go to the iframe url but rather stay on the actual page. Please review it if you will and let me know if the changes will collide with anything or cause anything crazy. Thanks!
in Service/Session.php
@ line 674

if (isset($_GET['iframe'])) {
    $this->changeLanguage($defaultLanguage, $url);
} else {

in Service/Url/Url.php
@ line 379

if ($this->request->isSwitching() && !isset($_GET['iframe'])) {

@ line 793

if (!$this->shouldAddPrefix($requestedLanguage) && !isset($_GET['iframe'])) {

@ line 823

if (strstr($url, $segmentsBefore)) {
    $url = str_replace($segmentsBefore, $segmentsAfter, $url);
} elseif (isset($_GET['iframe'])) {
    $url = $segmentsBefore.'?iframe=true';
} else {
    $url = $segmentsAfter;

in Service/Parser.php
Add function

 * replaceIframeSrc
 * Append iframe src with iframe=true so the url don't get tracked
 * @param  string  $template
 * @return string
public function replaceIframeSrc($template)
    $pattern = '/<iframe.*?src="(.*?)".*?<\/iframe>/';
    preg_match_all($pattern, $template, $matches);

    foreach ($matches[1] as $match) {
        if ($position = strpos($match, '?')) {
            $replacement = substr_replace($match, 'iframe=true&', $position + 1, 0);
        } else {
            $replacement = $match.'?iframe=true';
        $template = str_replace($match, $replacement, $template);

    return $template;

in ext.publisher.php
@ line 1303

$final_template = $parser->replaceIframeSrc($final_template);

BoldMinded (Brian)

Feb 07, 2019

Thanks for sending this code. I feel like this is a pretty heavy handed and specific approach though. I’m going to have to think about this for a bit to see if it’s something I want to add to the core codebase.

In the meantime I would suggest documenting your changes in your project so you can re-apply the patch if you upgrade Publisher in the future.


BoldMinded (Brian)

Feb 10, 2019

Comment has been marked private.


Hop Studios

Feb 11, 2019

Comment has been marked private.


BoldMinded (Brian)

Feb 12, 2019

Thanks, I added that change to my repo.


BoldMinded (Brian)

May 02, 2019

So, this is causing an issue with YT’s autoplay feature when embedding, so I’m making it so that you have to set a hidden config value before it will add ?publisher_iframe=true to the iframe source, thus preventing the redirects. In 2.11.0 and going forward, you will need to add this to your config.php file:

$config['publisher_fix_iframe_src'] = true;

Login to reply


For add-on support, please use the Support section. General inquries and pre-sale questions can be sent to