Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions assets/css/stackfolio-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions assets/images/video-thumb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 7 additions & 8 deletions includes/class-stackfolio-album.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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(
Expand All @@ -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;
Expand Down
Loading