-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathboot.php
75 lines (62 loc) · 3.17 KB
/
boot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
use Alexplusde\MediaManagerResponsive\Media;
use Alexplusde\MediaManagerResponsive\Type;
use Alexplusde\MediaManagerResponsive\TypeGroup;
use Alexplusde\MediaManagerResponsive\TypeInjector;
if (rex_addon::get('yform')->isAvailable()) {
rex_yform_manager_dataset::setModelClass(
'rex_media_manager_type_group',
TypeGroup::class,
);
rex_yform_manager_dataset::setModelClass(
'rex_media_manager_type_meta',
Type::class,
);
}
// rex_extension::register('MEDIA_FORM_EDIT', array('rex_media_plus', 'mediapool_edit_svg_viewbox'));
rex_extension::register('MEDIA_FORM_ADD', Media::mediapool_updated_svg_viewbox(...));
// rex_extension::register('MEDIA_FORM_ADD', array('rex_media_plus', 'mediapool_add_svg_viewbox'));
if (rex_addon::get('cache_warmup')->isAvailable()) {
if ('enhanced' === rex_config::get('media_manager_responsive', 'cache_warmup')) {
rex_extension::register('PACKAGES_INCLUDED', static function () {
rex_addon::get('cache_warmup')->setConfig('chunkSizePages', 1);
});
rex_extension::register('CACHE_WARMUP_IMAGES', static function (rex_extension_point $ep) {
// $images = $ep->getSubject();
return [];
});
}
}
if (rex::isFrontend() && '' != rex_config::get('media_manager_responsive', 'auto_inject_type')) {
rex_extension::register('OUTPUT_FILTER', static function (rex_extension_point $ep) {
$html = $ep->getSubject();
return TypeInjector::injectType($html, rex_config::get('media_manager_responsive', 'auto_inject_type'));
});
}
// Wenn Backend-Seite media_manager_types, dann in REDAXOs Datelist-EP einhängen
if (rex::isBackend() && rex_be_controller::getCurrentPage() == 'media_manager/types') {
rex_extension::register('REX_LIST_GET', function (rex_extension_point $ep) {
/** @var rex_list $subject */
$subject = $ep->getSubject();
$media = Media::get('media_manager_responsive_preview_image.jpg');
if($media) {
// Liste um Bild erweitern
$subject->addColumn('preview', 'Vorschau');
$subject->setColumnPosition('preview', 2);
$subject->setColumnLabel('preview', 'Vorschau');
$subject->setColumnFormat('preview', 'custom', function ($params) use ($media) {
$list = $params['list'];
$type = $list->getValue('name');
$rex_managed_media = \rex_media_manager::create($type, $media->getFilename())->getMedia();
$height = $rex_managed_media->getHeight() ?? 0;
$width = $rex_managed_media->getWidth() ?? 0;
$imagetype = $rex_managed_media->getFormat() ?? "image/jpeg";
$return = '<a href="/media/' . $type ."/". $media->getFileName() . '" target="_blank"><img src="/media/' . $type ."/". $media->getFileName() . '" style="max-width: 120px; max-height: 120px;"></a>';
$return .= '<span class="badge badge-primary">' . $width . 'px ✕ '. $height . 'px</span>';
$return .= ' <span class="badge badge-secondary">' . $imagetype . '</span>';
return $return;
});
}
return $subject;
});
}