Skip to content

Add a config option like sanitizeCpImageUploads but for plugin/module/CLI requests #15430

Closed Answered by brandonkelly
johndwells asked this question in Ideas
Discussion options

You must be logged in to vote

Just discussed this internally. It would be a little confusing to have two separate config settings that determine sanitization, so instead I added a new $sanitizeOnUpload property to craft\elements\Asset. If it’s set, it will take precedence over sanitizeCpImageUploads + the request type.

You can set it to false by registering an EVENT_BEFORE_SAVE event handler from a module:

use craft\base\Element;
use craft\base\Event;
use craft\elements\Asset;
use craft\events\ModelEvent;

Event::on(Asset::class, Element::EVENT_BEFORE_SAVE, function(ModelEvent $event) {
    /** @var Asset $asset */
    $asset = $event->sender;
    $asset->sanitizeOnUpload = false;
});

This is for 4.11 and 5.3+, so you…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants