You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having a few issue with a plugin that was created for adding attribute loading="lazy" to our iframes.
The plugin does what it is supposed to do but when it is enabled we noticed that it breaks our redirects.
If plugin is activated the response header return 200 status code for pages that do not exist which results in a white page being shown.
If we deactive plugin then pages that do not exist return 302 (as they should) and redirects to our "pagenotfound" page. plg_lazyloadiframes.zip
Attached is the plg with xml and php file. Please also find code below for easier access.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I am having a few issue with a plugin that was created for adding attribute loading="lazy" to our iframes.
The plugin does what it is supposed to do but when it is enabled we noticed that it breaks our redirects.
If plugin is activated the response header return 200 status code for pages that do not exist which results in a white page being shown.
If we deactive plugin then pages that do not exist return 302 (as they should) and redirects to our "pagenotfound" page.
plg_lazyloadiframes.zip
Attached is the plg with xml and php file. Please also find code below for easier access.
Hope someone can point me in the right direction.
Thanks
`<?php
/**
@Package Joomla.Plugin
@subpackage System.LazyLoadIframes
@copyright (C) 2011 Open Source Matters, Inc. https://www.joomla.org
@license GNU General Public License version 2 or later; see LICENSE.txt
@phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
*/
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Plugin\CMSPlugin;
// phpcs:disable PSR1.Files.SideEffects
defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
System plugin to lazyload iframes.
/
class PlgSystemLazyLoadIframes extends CMSPlugin
{
/*
*/
protected $app;
/**
Method to catch the onAfterRender event.
This event is triggered after the framework has rendered the application.
When this event is triggered the output of the application is available in the response buffer.
@return void
@SInCE 2.5
*/
public function onAfterRender()
{
// Check that we are in the site application.
if (!$this->app->isClient('site')) {
return;
}
$buffer = $this->app->getBody();
// skip if no iframe present
if (strpos( $buffer, '<iframe' ) === false ) {
return;
}
$buffer = preg_replace('/<iframe/mi', '<iframe loading="lazy" ', $buffer);
$this->app->setBody($buffer);
}
}
`
Beta Was this translation helpful? Give feedback.
All reactions