Skip to content

Instantly share code, notes, and snippets.

@webnitros
Created February 6, 2019 11:40
Show Gist options
  • Save webnitros/c0893854db0b18fd89221f2ca72416a1 to your computer and use it in GitHub Desktop.
Save webnitros/c0893854db0b18fd89221f2ca72416a1 to your computer and use it in GitHub Desktop.
События для управления превью изображений для minishop2 MODX
<?php
/**
* Created by Andrey Stepanenko.
* User: webnitros
* Date: 06.02.2019
* Time: 18:38
*/
switch ($event->name) {
case 'OnMediaSourceGetProperties':
// Автоматчиски убирает наложение водяного знака на фотографию
if (isset($_REQUEST['msgs_upload'])) {
if (isset($scriptProperties['properties'])) {
$properties = $this->modx->fromJSON($scriptProperties['properties']);
if (isset($properties['msGallerySearch']) and (isset($properties['msGallerySearch']['value']) and $properties['msGallerySearch']['value'] == 1)) {
if (isset($properties['thumbnails']) and isset($properties['thumbnails']['value'])) {
$thumbnails = $this->modx->fromJSON($properties['thumbnails']['value']);
foreach ($thumbnails as $key => $params) {
if (isset($params['fltr'])) {
unset($thumbnails[$key]['fltr']);
}
}
$properties['thumbnails']['value'] = $this->modx->toJSON($thumbnails);
}
}
$this->modx->event->output($this->modx->toJson($properties));
return $properties;
}
}
break;
case 'OnMODXInit':
// Блокировка генерации превью
if (isset($_REQUEST['action']) and isset($_REQUEST['method'])) {
if (($_REQUEST['action'] == 'mgr/gallery/multiple' and $_REQUEST['method'] == 'generate') or ($_REQUEST['action'] == 'mgr/controller/product/multiple' and $_REQUEST['method'] == 'imagegeneration')) {
exit($modx->toJSON(array(
'success' => false,
'message' => 'Обновление превью запрещено',
'object' => array()
)));
}
}
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment