Created
August 12, 2022 06:39
-
-
Save HDDen/45a0eedb763f11748e349a943382cd1b to your computer and use it in GitHub Desktop.
Обёёртка для output_modifier, создаёт webp, ленивую загрузку, позволяет модифицировать html. Идём в админку -> Плагины -> Новый плагин. Вбиваем код, название, затем в "Системных событиях" включаем OnWebPagePrerender
This file contains 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
<?php | |
/** | |
* MODX Evo | |
*/ | |
// $e = &$modx->event; | |
// switch ($e->name) { | |
// case "OnWebPagePrerender":{ | |
// include_once $_SERVER['DOCUMENT_ROOT'] . '/madmen/output_modifier/core_scripts/output_modifier.php'; | |
// if (function_exists('modifyImagesWebp')){ | |
// $content = $modx->documentOutput; // получаем html | |
// $content = modifyImagesWebp($content); // модифицируем | |
// $modx->documentOutput = $content; // возвращаем модифицированное | |
// } | |
// } | |
// } | |
/** | |
* MODX Revo | |
*/ | |
// $cid = $modx->resource->get('id'); | |
// $exclude = $modx->getOption('exclude',$scriptProperties,'12'); | |
// if(empty($cid)) { return; } | |
// if(in_array($cid,explode(',',$exclude))) { return; } | |
// include_once $_SERVER['DOCUMENT_ROOT'] . '/madmen/output_modifier/core_scripts/output_modifier.php'; | |
// if (function_exists('modifyImagesWebp')){ | |
// $output = &$modx->resource->_output; | |
// $output = modifyImagesWebp($output); | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment