Skip to content

Commit

Permalink
Fixes for directory-synced MPOs
Browse files Browse the repository at this point in the history
Previous code depended on a quirk of the upload code which renamed
MPO files to jpg.
  • Loading branch information
ejegg committed Nov 13, 2017
1 parent ecdd424 commit 35484b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions include/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ function Stereo_render_element_content($content, $picture)
if ( !preg_match ( '/.*mpo$/i', $picture['file'] ) ) {
return $content;
}
$gif_relative = preg_replace( '/jpg$/i', 'gif', $picture['path'] );
$picture_path = $picture['path'];
$without_extension = substr( $picture_path, 0, strrpos( $picture_path, '.' ) );
$gif_relative = $without_extension . '.gif';
$gif_absolute_path = Stereo_get_absolute_path( $gif_relative );
$r_relative_path = preg_replace( '/.jpg$/i', '_r.jpg', $picture['path'] );
$l_relative_path = preg_replace( '/.jpg$/i', '_l.jpg', $picture['path'] );
$r_relative_path = $without_extension . '_r.jpg';
$l_relative_path = $without_extension . '_l.jpg';
$r_absolute_path = Stereo_get_absolute_path( $r_relative_path );
$l_absolute_path = Stereo_get_absolute_path( $l_relative_path );

if ( !file_exists( $r_absolute_path ) ) {
Stereo_split_mpo( $picture['path'], $r_absolute_path, $l_absolute_path );
Stereo_split_mpo( $picture_path, $r_absolute_path, $l_absolute_path );
}
if ( !file_exists( $gif_absolute_path ) ) {
Stereo_generate_gif( $r_absolute_path, $l_absolute_path, $gif_absolute_path );
Expand Down
1 change: 1 addition & 0 deletions main.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
define('STEREO_MODE_WALL_EYED', 'wall');

$conf['picture_ext'][] = 'mpo';
$conf['file_ext'][] = 'mpo';

include_once( __DIR__ . '/include/functions.php' );

Expand Down

0 comments on commit 35484b4

Please sign in to comment.