Skip to content

Instantly share code, notes, and snippets.

View jenswittmann's full-sized avatar

Jens Wittmann – Gestaltung & Entwicklung jenswittmann

View GitHub Profile
@jenswittmann
jenswittmann / restirctusermanagement.plugin.php
Created January 22, 2023 19:06
MODX CMP User restriction Plugin
<?php
if ($modx->context->get("key") == "mgr") {
if ($modx->user->get("sudo") || $modx->user->isMember("Administrator")) {
return;
}
switch ($modx->event->name) {
case "OnMODXInit":
$action = $modx->getOption("action", $_REQUEST, "");
@jenswittmann
jenswittmann / gist:97bc2e295bac7d2619ed4505641bed52
Created December 26, 2018 18:54
Use MODX BabelLinks snippet for canonical Metatags
# add snippet into <head>
[[BabelLinks?
&tpl=`babelCanonicalTag`
&showCurrent=`1` ]]
# create chunk with name babelCanonicalTag
<link rel="alternate" hreflang="[[+cultureKey]]" href="[[+url]]">
@jenswittmann
jenswittmann / pdf2image.php
Last active October 22, 2023 11:16
MODX pdf2image Snippet
<?php
# vars
$filePath = $modx->getOption('input', $scriptProperties, '');
$savePath = "assets/components/phpthumbof/cache/poster_" . md5($filePath) . ".jpg";
# check file exists and is PDF
if (!file_exists(MODX_BASE_PATH . $filePath) || mime_content_type(MODX_BASE_PATH . $filePath) != "application/pdf") {
return $filePath;
}
@jenswittmann
jenswittmann / resizeImage.php
Last active October 22, 2023 11:20
MODX resizeImage Snippet (modern pthumb replacement with srcset generation and very low options, but works on IONOS too)
<?php
# vars
$lib = $modx->getOption("resizeImage_imageLib", null, "cli");
$libPath = $modx->getOption("resizeImage_imageLibPath", null, "/Applications/MAMP/Library/bin/convert");
$mode = $modx->getOption("mode", $scriptProperties, "");
$input = $modx->getOption("input", $scriptProperties, "");
$sizes = $modx->getOption("options", $scriptProperties, "");
$quality = $modx->getOption("quality", $scriptProperties, 70);
$cultureKey = $modx->getOption("cultureKey");