diff --git a/assets/css/stackfolio-admin.css b/assets/css/stackfolio-admin.css index 7da4af5..0bbfabd 100644 --- a/assets/css/stackfolio-admin.css +++ b/assets/css/stackfolio-admin.css @@ -7,12 +7,12 @@ margin-top: 0.5em; } +/* Floated, not flex: jQuery UI sortable only sorts sideways when + items float. */ .stackfolio-media-list { - display: flex; - flex-wrap: wrap; - gap: 8px; + display: flow-root; margin: 12px 0; - padding: 12px; + padding: 12px 4px 4px 12px; min-height: 40px; background: #f6f7f7; border: 1px dashed #c3c4c7; @@ -24,9 +24,10 @@ .stackfolio-media-item { position: relative; + float: left; width: 100px; height: 100px; - margin: 0; + margin: 0 8px 8px 0; background: #fff; border: 1px solid #dcdcde; cursor: move; diff --git a/assets/images/video-thumb.svg b/assets/images/video-thumb.svg new file mode 100644 index 0000000..b5e76cc --- /dev/null +++ b/assets/images/video-thumb.svg @@ -0,0 +1 @@ + diff --git a/includes/class-stackfolio-album.php b/includes/class-stackfolio-album.php index 25f316a..9148bcb 100644 --- a/includes/class-stackfolio-album.php +++ b/includes/class-stackfolio-album.php @@ -81,7 +81,7 @@ public static function get_items( $post_id, array $args = array() ) { $media = array(); foreach ( self::get_media_ids( $post_id ) as $attachment_id ) { - $item = self::attachment_item( $attachment_id, $post_id, $args ); + $item = self::attachment_item( $attachment_id, $args ); if ( $item ) { $media[] = $item; } @@ -107,11 +107,10 @@ public static function get_items( $post_id, array $args = array() ) { * Lightbox item for one Media Library attachment. * * @param int $attachment_id Attachment ID. - * @param int $post_id Album ID (for the fallback poster). * @param array $args Render arguments. * @return array|null */ - private static function attachment_item( $attachment_id, $post_id, array $args ) { + private static function attachment_item( $attachment_id, array $args ) { $attachment = get_post( $attachment_id ); if ( ! $attachment || 'attachment' !== $attachment->post_type ) { return null; @@ -137,11 +136,11 @@ private static function attachment_item( $attachment_id, $post_id, array $args ) } if ( 0 === strpos( $mime, 'video/' ) && $args['videos'] ) { + // Only the video's own image is a poster. Without one the player shows the + // video's first frame, and the thumbnail strip a neutral video icon, so the + // video never looks like a copy of the album cover. $poster = get_the_post_thumbnail_url( $attachment_id, 'large' ); - if ( ! $poster ) { - $poster = get_the_post_thumbnail_url( $post_id, 'large' ); - } - $item = array( + $item = array( 'video' => array( 'source' => array( array( @@ -155,7 +154,7 @@ private static function attachment_item( $attachment_id, $post_id, array $args ) 'playsinline' => true, ), ), - 'thumb' => $poster ? $poster : '', + 'thumb' => $poster ? $poster : STACKFOLIO_URL . 'assets/images/video-thumb.svg', ); if ( $poster ) { $item['poster'] = $poster;