It's better when it's simple

User Tools

Site Tools


Table of Contents


handles media resizing or cropping
use configured image manipulation engine (GD or IM) to resize or crop media as needed

This event can be used to alter the resizing or cropping process in lib/exe/fetch.php. It can be used to prevent the native resizing algorithm in whatever case is required, for example, if there is a need to use a specific algorithm not available in DokuWiki, or disable resizing for certain file extensions. This is processed before the MEDIA_SENDFILE but after FETCH_MEDIA_STATUS and offers a BEFORE and an AFTER processing.

The native resizing algorithm can be prevented by calling $event->preventDefault() in the BEFORE process.

If manipulating the image, the processed image's URL should be set as $data['file'] in the AFTER process.

Passed Data

  • $data['media'] – The id for the called file
  • $data['file'] – The filename of the file about to be delivered, can be modified by your plugin
  • $data['mime'] – The Mime-Type of the file, can be modified by your plugin
  • $data['download'] – Whether the file is to be downloaded or displayed inline
  • $data['cache'] – The wanted cache behavior (-1 = cache forever, 0 = never cache, >0 cache time in seconds), can be modified by your plugin
  • $data['ext'] – Extension of the file
  • $data['width'] – Images only: the wanted width as specified in the request
  • $data['height'] – Images only: the wanted height as specified in the request
  • $data['status'] – The current status code of the request
  • $data['statusmessage'] – The status message corresponding to the status above

See also

devel/event/media_resize.txt · Last modified: 2020-09-28 18:40 by samyelman

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki