0

We want the public uploads to remain in raw state. Is it possible to disable image cleansing for entries created through public facing form? (Image cleansing to continue working for uploads through Control Panel.)

1

The imageDriver setting just determines which driver Craft should use when working with images (GD or ImageMagick) for things like image cleansing and image transforms. So changing its value will not affect whether images are cleansed on upload; just which driver would be used for that process.

If you want to disable image cleansing on the front end, you will need to write a plugin that handles the upload. You can find out how to do that from this answer: https://craftcms.stackexchange.com/a/9675/9

2
  • null would also disable it, right? – Souvik Das Gupta Sep 30 '15 at 10:46
  • No; setting it to null will give you the same result as setting it to 'auto' (Craft will use ImageMagick if it’s available; otherwise GD). – Brandon Kelly Sep 30 '15 at 13:34
0

I can think of a few ways to go about this and probably the easiest one is to do something like this completely untested code from your craft/config/general.php file.

return array(
    'imageDriver' => strpos($_SERVER['REQUEST_URI'], 'admin') !== false ? 'imagick' : 'gd',
);

Of course you'd change 'admin' to whatever your cpTrigger config setting is set to.

I'd also be extremely curious to know what the reasoning for this was, too. :)

Alternatively, if you wanted to do this from a Craft plugin, then you could add an init() method to your base plugin file and do something like this:

public function init()
{
    if (craft()->request->isCpRequest())
    {
        craft()->config->set('imageDriver', 'imagick');
    }
    else
    {
        craft()->config->set('imageDriver', 'gd');
    }

    parent::init();
}
4
  • The form is being handled by a custom plugin action. Can the config be overridden temporarily inside the action? – Souvik Das Gupta Sep 30 '15 at 6:24
  • Updated answer. – Brad Bell Sep 30 '15 at 6:33
  • Thanks. Doing this because we want the public uploads to remain in raw state — no manipulations / transformations. – Souvik Das Gupta Sep 30 '15 at 6:37
  • FWIW, Craft is going to re-save all uploaded images to strip them of any potentially malicious embedded code regardless of the image library installed on the server. – Brad Bell Sep 30 '15 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.