From 88511acff2227c01603e01ff50b9c94a40ff52c0 Mon Sep 17 00:00:00 2001 From: Makarand Mane Date: Sun, 15 Nov 2026 17:43:02 +0530 Subject: [PATCH] Fix sideways drag in the album editor and video thumbnails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the two problems found while testing v1.0.1 on a staging site, before submitting to WordPress.org. ## #32 Dragging photos sideways in the album editor doesn't reorder them - `assets/css/stackfolio-admin.css`: the media list uses floated tiles instead of flexbox. jQuery UI sortable only sorts sideways when items float. With flexbox it treated the list as vertical and ignored left/right drags. ## #33 Uploaded videos without a poster look like a copy of the album cover - `includes/class-stackfolio-album.php`: only the video's own image is used as its poster. Without one, the player shows the video directly, and the thumbnail strip shows a new neutral icon, `assets/images/video-thumb.svg`. ## Testing on staging (WordPress Playground, WordPress 7.1, PHP 8.3, Elementor, WP_DEBUG on) On v1.0.1 from the release zip: - **Migration from Album Station:** 3 albums, categories, videos and the API key moved; an unrelated `album` post left alone. - **YouTube playlist, with the YouTube API mocked:** correct request (key and playlist ID); private and deleted videos skipped; videos before photos as migrated; video plays; result cached (1 API call across reloads). - **Uploaded MP4:** recorded H.264 MP4 uploaded, added through the media picker, plays in the lightbox with controls and inline playback. - **Album editing:** media picker, remove, save. - **Block:** filters, lightbox, Escape returns focus. - **Shortcode** and legacy `[feature_album]`. - **Elementor:** legacy `as-gallery` page, editor re-render, new widget. - **Mobile 375px:** one column, no horizontal scroll, lightbox fits. - **Uninstall:** settings removed, albums kept. - **Debug log:** no StackFolio notices or warnings. On this branch (exact package copy): - A sideways drag now reorders (`13,14,15,22` → `22,13,14,15`) and saves. - The video shows directly with the neutral thumbnail and plays. - Debug log clean. - PHPCS, PHPStan, unit tests and CSS lint pass locally. ## What happens on merge The zip changes, so this releases **v1.0.2**, the version to submit. Closes #32 Closes #33 --- assets/css/stackfolio-admin.css | 11 ++++++----- assets/images/video-thumb.svg | 1 + includes/class-stackfolio-album.php | 15 +++++++-------- 3 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 assets/images/video-thumb.svg 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;