forked from leftypol/leftypol
GdMediaHandler.php: update
This commit is contained in:
parent
cfca4c3c0e
commit
78c6fe1826
1 changed files with 15 additions and 9 deletions
|
@ -83,7 +83,8 @@ class GdMediaHandler implements MediaHandler {
|
|||
string $source_file_path,
|
||||
string $source_file_mime,
|
||||
string $source_file_kind,
|
||||
string $preferred_out_file_path,
|
||||
string $preferred_out_file_dir,
|
||||
string $preferred_out_file_name,
|
||||
string $preferred_out_mime,
|
||||
int $max_width,
|
||||
int $max_height
|
||||
|
@ -92,7 +93,7 @@ class GdMediaHandler implements MediaHandler {
|
|||
$height = \imagesy($gd);
|
||||
|
||||
if ($width <= $max_width && $height <= $max_height) {
|
||||
$out_path = $preferred_out_file_path . '.' . self::MIME_TO_EXT[$source_file_mime];
|
||||
$out_path = $preferred_out_file_dir . DIRECTORY_SEPARATOR . $preferred_out_file_name . '.' . self::MIME_TO_EXT[$source_file_mime];
|
||||
|
||||
if ($source_file_kind === self::FILE_KIND_UPLOADED) {
|
||||
if (!Fs\move_or_copy_uploaded($source_file_path, $out_path)) {
|
||||
|
@ -112,7 +113,7 @@ class GdMediaHandler implements MediaHandler {
|
|||
$height
|
||||
);
|
||||
} else {
|
||||
$out_path = $preferred_out_file_path . '.' . self::MIME_TO_EXT[$preferred_out_mime];
|
||||
$out_path = $preferred_out_file_dir . DIRECTORY_SEPARATOR . $preferred_out_file_name . '.' . self::MIME_TO_EXT[$preferred_out_mime];
|
||||
|
||||
$gd_other = self::createCanvas($preferred_out_mime, $max_width, $max_height);
|
||||
\imagecopyresampled($gd_other, $gd, 0, 0, 0, 0, $max_width, $max_height, $width, $height);
|
||||
|
@ -166,14 +167,16 @@ class GdMediaHandler implements MediaHandler {
|
|||
|
||||
public function installMediaAndGenerateThumb(
|
||||
mixed $handle,
|
||||
string $media_preferred_out_file_path,
|
||||
string $thumb_preferred_out_file_path,
|
||||
string $media_preferred_out_file_dir,
|
||||
string $media_preferred_out_file_name,
|
||||
string $thumb_preferred_out_file_dir,
|
||||
string $thumb_preferred_out_file_name,
|
||||
string $thumb_preferred_out_mime,
|
||||
int $thumb_max_width,
|
||||
int $thumb_max_height
|
||||
) {
|
||||
list($gd, $source_file_path, $source_file_mime, $source_file_kind) = $handle;
|
||||
$out_path = $media_preferred_out_file_path . '.' . self::MIME_TO_EXT[$source_file_mime];
|
||||
$out_path = $media_preferred_out_file_dir . DIRECTORY_SEPARATOR . $media_preferred_out_file_name . '.' . self::MIME_TO_EXT[$source_file_mime];
|
||||
|
||||
if ($this->strip_redraw) {
|
||||
if (!self::imageSaveTo($gd, $out_path, $source_file_mime)) {
|
||||
|
@ -196,7 +199,8 @@ class GdMediaHandler implements MediaHandler {
|
|||
$source_file_path,
|
||||
$source_file_mime,
|
||||
$source_file_kind,
|
||||
$thumb_preferred_out_file_path,
|
||||
$thumb_preferred_out_file_dir,
|
||||
$thumb_preferred_out_file_name,
|
||||
$thumb_preferred_out_mime,
|
||||
$thumb_max_width,
|
||||
$thumb_max_height
|
||||
|
@ -205,7 +209,8 @@ class GdMediaHandler implements MediaHandler {
|
|||
|
||||
public function generateThumb(
|
||||
mixed $handle,
|
||||
string $preferred_out_file_path,
|
||||
string $preferred_out_file_dir,
|
||||
string $preferred_out_file_name,
|
||||
string $preferred_out_mime,
|
||||
int $max_width,
|
||||
int $max_height
|
||||
|
@ -217,7 +222,8 @@ class GdMediaHandler implements MediaHandler {
|
|||
$source_file_path,
|
||||
$source_file_mime,
|
||||
$source_file_kind,
|
||||
$preferred_out_file_path,
|
||||
$preferred_out_file_dir,
|
||||
$preferred_out_file_name,
|
||||
$preferred_out_mime,
|
||||
$max_width,
|
||||
$max_height
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue