Skip to content

Instantly share code, notes, and snippets.

@HDDen
Created August 12, 2022 06:39
Show Gist options
  • Save HDDen/45a0eedb763f11748e349a943382cd1b to your computer and use it in GitHub Desktop.
Save HDDen/45a0eedb763f11748e349a943382cd1b to your computer and use it in GitHub Desktop.
Обёёртка для output_modifier, создаёт webp, ленивую загрузку, позволяет модифицировать html. Идём в админку -> Плагины -> Новый плагин. Вбиваем код, название, затем в "Системных событиях" включаем OnWebPagePrerender
<?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