mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
Issue 2331 fix large file sync timeouts
Put `getimagesize` behind a mimetype check, so it doesn't waste processing time on large files like videos that are incompatible.
This commit is contained in:
committed by
Pierrick Le Gall
parent
0cb6914e5a
commit
24c51f7225
@@ -188,37 +188,45 @@ function get_sync_metadata($infos)
|
|||||||
$file = original_to_representative($file, $infos['representative_ext']);
|
$file = original_to_representative($file, $infos['representative_ext']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists('mime_content_type') && in_array(mime_content_type($file), array('image/svg+xml', 'image/svg')))
|
if (function_exists('mime_content_type'))
|
||||||
{
|
{
|
||||||
$xml = file_get_contents($file);
|
$mime_type = mime_content_type($file);
|
||||||
|
|
||||||
$xmlget = simplexml_load_string($xml);
|
if (str_starts_with($mime_type, 'image/'))
|
||||||
$xmlattributes = $xmlget->attributes();
|
{
|
||||||
$width = $xmlattributes->width;
|
if (in_array($mime_type, array('image/svg+xml', 'image/svg')))
|
||||||
$height = $xmlattributes->height;
|
{
|
||||||
$vb = (string) $xmlattributes->viewBox;
|
$xml = file_get_contents($file);
|
||||||
|
|
||||||
if (isset($width) and $width != "")
|
$xmlget = simplexml_load_string($xml);
|
||||||
{
|
$xmlattributes = $xmlget->attributes();
|
||||||
$infos['width'] = (int) $width;
|
$width = $xmlattributes->width;
|
||||||
} elseif (isset($vb))
|
$height = $xmlattributes->height;
|
||||||
{
|
$vb = (string) $xmlattributes->viewBox;
|
||||||
$infos['width'] = round(explode(" ", $vb)[2]);
|
|
||||||
|
if (isset($width) and $width != "")
|
||||||
|
{
|
||||||
|
$infos['width'] = (int) $width;
|
||||||
|
} elseif (isset($vb))
|
||||||
|
{
|
||||||
|
$infos['width'] = round(explode(" ", $vb)[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($height) and $height != "")
|
||||||
|
{
|
||||||
|
$infos['height'] = (int) $height;
|
||||||
|
} elseif (isset($vb))
|
||||||
|
{
|
||||||
|
$infos['height'] = round(explode(" ", $vb)[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Only get image size for images. This cuts significant time with large videos.
|
||||||
|
if ($image_size = @getimagesize($file))
|
||||||
|
{
|
||||||
|
$infos['width'] = $image_size[0];
|
||||||
|
$infos['height'] = $image_size[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($height) and $height != "")
|
|
||||||
{
|
|
||||||
$infos['height'] = (int) $height;
|
|
||||||
} elseif (isset($vb))
|
|
||||||
{
|
|
||||||
$infos['height'] = round(explode(" ", $vb)[3]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($image_size = @getimagesize($file))
|
|
||||||
{
|
|
||||||
$infos['width'] = $image_size[0];
|
|
||||||
$infos['height'] = $image_size[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($is_tiff)
|
if ($is_tiff)
|
||||||
|
|||||||
Reference in New Issue
Block a user