[ImageThumbnail] Implement image resizing with Intervention/Image

This commit is contained in:
2021-04-16 10:46:53 +00:00
parent ee87961d96
commit 4358656c55
5 changed files with 116 additions and 4 deletions

View File

@@ -206,4 +206,34 @@ abstract class Utils
return ['file_path' => $filepath, 'mimetype' => 'image/svg+xml', 'title' => null];
}
}
// ------------------------------
/**
* Get the minor part of a mimetype. image/webp -> image
*/
public static function mimetypeMajor(string $mime)
{
return explode('/', self::mimeBare($mime))[0];
}
/**
* Get the minor part of a mimetype. image/webp -> webp
*/
public static function mimetypeMinor(string $mime)
{
return explode('/', self::mimeBare($mime))[1];
}
/**
* Get only the mimetype and not additional info (separated from bare mime with semi-colon)
*/
public static function mimeBare(string $mimetype)
{
$mimetype = mb_strtolower($mimetype);
if (($semicolon = mb_strpos($mimetype, ';')) !== false) {
$mimetype = mb_substr($mimetype, 0, $semicolon);
}
return trim($mimetype);
}
}