diff options
author | shadlaws <shad@shadlaws.com> | 2013-02-09 18:12:08 +0100 |
---|---|---|
committer | shadlaws <shad@shadlaws.com> | 2013-02-09 18:12:08 +0100 |
commit | 8dcdb3b8e14c58a65fb98a906dc8916d481c2af4 (patch) | |
tree | affca03f6fe03ba8fec9bc75ce7463cc4a75c2ce | |
parent | f4ecb7e65850ca0cac9f7d963c34f7cd20ee9446 (diff) |
#1997 - Update movie dimensions and mime type if previously set without FFmpeg.
- Added code to check/correct movie width, height, and mime in graphics::generate.
As the comment says in the commit, this isn't ideal, but doing it in an upgrade
script wouldn't be very ideal either.
-rw-r--r-- | modules/gallery/helpers/graphics.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 4df57fba..e8df56ed 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -149,6 +149,19 @@ class graphics_Core { if (@filesize($output_file) == 0) { try { movie::extract_frame($working_file, $output_file, $movie_options_wrapper->movie_options); + // If we're here, we know ffmpeg is installed and the movie is valid. Because the + // user may not always have had ffmpeg installed, the movie's width, height, and + // mime type may need updating. Let's use this opportunity to make sure they're + // correct. It's not optimal to do it at this low level, but it's not trivial to find + // these cases quickly in an upgrade script. + list ($width, $height, $mime_type) = movie::get_file_metadata($working_file); + // Only set them if they need updating to avoid marking them as "changed" + if (($item->width != $width) || ($item->height != $height) || + ($item->mime_type != $mime_type)) { + $item->width = $width; + $item->height = $height; + $item->mime_type = $mime_type; + } } catch (Exception $e) { // Didn't work, likely because of MISSING_FFMPEG - use placeholder graphics::_replace_image_with_placeholder($item, $target); |