Added ImageDownloadingEvent that allows extensions to stop a user from viewing an image or perform other operations on the image before the image is downloaded to the user

This commit is contained in:
Matthew Barbour
2020-06-16 18:40:13 -05:00
committed by Shish
parent 40b80bca93
commit 9b5d963aa3
8 changed files with 130 additions and 14 deletions

View File

@ -28,9 +28,9 @@ class RandomImage extends Extension
}
if ($action === "download") {
$page->set_mode(PageMode::DATA);
$page->set_type($image->get_mime_type());
$page->set_data(file_get_contents($image->get_image_filename()));
if (!is_null($image)) {
send_event(new ImageDownloadingEvent($image, $image->get_image_filename(), $image->get_mime_type()));
}
} elseif ($action === "view") {
send_event(new DisplayingImageEvent($image));
} elseif ($action === "widget") {