Printing the images loaded by Lazy Load for Joomla

3 years 7 months ago - 3 years 7 months ago #9325 by sfg85
As you know, you cannot print the images with lazy loading. I think it would be useful to add an excluding option which will exclude a page /templates/your_template/COMPONENT.PHP, which was intended as a print version of a document. Unfortunately, there isn't an option for excluding such URLs, generated with this file (you may exclude only whole URL — but it is not convenient), so I had to recode lazyloadforjoomla.php, redefining the function onAfterRender():
public function onAfterRender()
    {
	
		$viewRel = explode('?', $_SERVER["REQUEST_URI"]); 
		$viewRel = $viewRel[1];
		
        if($this->_execute == true && $viewRel != 'tmpl=component&print=1')

        {
            $blankimage = JURI::base().'plugins/system/lazyloadforjoomla/blank.gif';
            $body = JFactory::getApplication()->getBody(false);

            $pattern = "@<img[^>]*src=[\"\']([^\"\']*)[\"\'][^>]*>@";
            preg_match_all($pattern, $body, $matches);

            if($this->params->get('exclude_imagenames') AND !empty($matches))
            {
                $this->excludeImageNames($matches);
            }

            if(!empty($matches))
            {
                foreach($matches[0] as $match)
                {
                    $matchlazy = str_replace('src=', 'src="'.$blankimage.'" data-src=', $match);
                    $body = str_replace($match, $matchlazy, $body);
                }

                JFactory::getApplication()->setBody($body);
            }
        }
    }

The result you may see here (there is a print button in the left corner of the article)

However, if I upgrade the version, I will need to change the code again. That's why I would like to ask you to make this option always availible without core editing.

Philip

3 years 7 months ago #9327 by Vitja
Hello Philip,

thank you for this valuable suggestion.

I will set it on the todo list and add this feature in the next release.

Have success!

Greetings

Kubik-Rubik Joomla! Extensions

Please support my work with a review in the Joomla! Extensions Directory: extensions.joomla.org/profile/profile/details/61997
3 years 7 months ago #9333 by Vitja
Hello Philip,

released new version with this feature: joomla-extensions.kubik-rubik.de/downloa...-for-joomla/joomla-3

Thank you for your suggestion!

Greetings

Kubik-Rubik Joomla! Extensions

Please support my work with a review in the Joomla! Extensions Directory: extensions.joomla.org/profile/profile/details/61997
The following user(s) said Thank You: sfg85
3 years 7 months ago #9334 by sfg85
Good day, Vitja!

Thank you for your excellent extention and your responsiveness!

Philip!
3 years 7 months ago #9337 by Vitja
You are welcome!

If you like the extension and the support, please write a review in the JED: extensions.joomla.org/extensions/core-en...te-performance/18035

Thank you!

Kubik-Rubik Joomla! Extensions

Please support my work with a review in the Joomla! Extensions Directory: extensions.joomla.org/profile/profile/details/61997
Time to create page: 0.122 seconds