Added extension constant lists to resize and rotate extensions so that they weren't rendering their controls ont he wrong image types
This commit is contained in:
parent
1fe18e7573
commit
014a4c2cd2
2 changed files with 10 additions and 3 deletions
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
class ResizeImage extends Extension
|
class ResizeImage extends Extension
|
||||||
{
|
{
|
||||||
|
const SUPPORTED_EXT = ["jpg","jpeg","png","gif","webp"];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Needs to be after the data processing extensions
|
* Needs to be after the data processing extensions
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +39,8 @@ class ResizeImage extends Extension
|
||||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
||||||
{
|
{
|
||||||
global $user, $config;
|
global $user, $config;
|
||||||
if ($user->is_admin() && $config->get_bool("resize_enabled")) {
|
if ($user->is_admin() && $config->get_bool("resize_enabled")
|
||||||
|
&& in_array($event->image->ext, self::SUPPORTED_EXT)) {
|
||||||
/* Add a link to resize the image */
|
/* Add a link to resize the image */
|
||||||
$event->add_part($this->theme->get_resize_html($event->image));
|
$event->add_part($this->theme->get_resize_html($event->image));
|
||||||
}
|
}
|
||||||
|
@ -68,7 +71,8 @@ class ResizeImage extends Extension
|
||||||
|
|
||||||
$image_obj = Image::by_id($event->image_id);
|
$image_obj = Image::by_id($event->image_id);
|
||||||
|
|
||||||
if ($config->get_bool("resize_upload") == true && ($image_obj->ext == "jpg" || $image_obj->ext == "png" || $image_obj->ext == "gif" || $image_obj->ext == "webp")) {
|
if ($config->get_bool("resize_upload") == true
|
||||||
|
&& in_array($event->type, self::SUPPORTED_EXT)) {
|
||||||
$width = $height = 0;
|
$width = $height = 0;
|
||||||
|
|
||||||
if ($config->get_int("resize_default_width") !== 0) {
|
if ($config->get_int("resize_default_width") !== 0) {
|
||||||
|
|
|
@ -31,6 +31,8 @@ class ImageRotateException extends SCoreException
|
||||||
*/
|
*/
|
||||||
class RotateImage extends Extension
|
class RotateImage extends Extension
|
||||||
{
|
{
|
||||||
|
const SUPPORTED_EXT = ["jpg","jpeg","png","gif","webp"];
|
||||||
|
|
||||||
public function onInitExt(InitExtEvent $event)
|
public function onInitExt(InitExtEvent $event)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
@ -41,7 +43,8 @@ class RotateImage extends Extension
|
||||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
||||||
{
|
{
|
||||||
global $user, $config;
|
global $user, $config;
|
||||||
if ($user->is_admin() && $config->get_bool("rotate_enabled")) {
|
if ($user->is_admin() && $config->get_bool("rotate_enabled")
|
||||||
|
&& in_array($event->image->ext, self::SUPPORTED_EXT)) {
|
||||||
/* Add a link to rotate the image */
|
/* Add a link to rotate the image */
|
||||||
$event->add_part($this->theme->get_rotate_html($event->image->id));
|
$event->add_part($this->theme->get_rotate_html($event->image->id));
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue