Skip to content
Open
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
16 changes: 16 additions & 0 deletions src/bp-templates/bp-nouveau/js/buddypress-activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -3209,6 +3209,22 @@ window.bp = window.bp || {};
response.data.saved = false;
response.data.js_preview = $( file.previewElement ).find( '.dz-video-thumbnail img' ).attr( 'src' );
self.dropzone_video.push( response.data );

// The thumbnail capture (bp.Nouveau.getVideoThumb) runs async and can still be
// in progress here. Backfill js_preview on this same object (already pushed
// above, by reference) once the capture finishes, instead of reading the
// <img> immediately and losing the preview.
if ( ! response.data.js_preview ) {
var thumbnailCheck = setInterval(
function () {
if ( $( file.previewElement ).closest( '.dz-preview' ).hasClass( 'dz-has-no-thumbnail' ) || $( file.previewElement ).closest( '.dz-preview' ).hasClass( 'dz-has-thumbnail' ) ) {
response.data.js_preview = $( file.previewElement ).find( '.dz-video-thumbnail img' ).attr( 'src' );
clearInterval( thumbnailCheck );
}
}
);
}

return file.previewElement.classList.add( 'dz-success' );
} else {
var node, _i, _len, _ref, _results;
Expand Down
2 changes: 1 addition & 1 deletion src/bp-templates/bp-nouveau/js/buddypress-activity.min.js

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions src/bp-video/bp-video-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,6 @@ function bp_video_add_generate_thumb_background_process( $video_id ) {
$video->privacy,
array(
'forums',
'comment',
'message',
),
true
Expand Down Expand Up @@ -4619,9 +4618,22 @@ function bb_video_get_attachment_symlink( $video, $attachment_id, $size, $genera
}
} elseif ( ! $file ) {

bp_video_regenerate_attachment_thumbnails( $attachment_id );
$unavailable_sizes = get_post_meta( $attachment_id, '_bb_video_thumb_unavailable_sizes', true );
if ( ! is_array( $unavailable_sizes ) ) {
$unavailable_sizes = array();
}

if ( ! in_array( $size, $unavailable_sizes, true ) ) {
bp_video_regenerate_attachment_thumbnails( $attachment_id );

$file = image_get_intermediate_size( $attachment_id, $size );
$file = image_get_intermediate_size( $attachment_id, $size );

// The source video is too small to ever produce this size; stop retrying it on every request.
if ( ! $file ) {
$unavailable_sizes[] = $size;
update_post_meta( $attachment_id, '_bb_video_thumb_unavailable_sizes', $unavailable_sizes );
}
}

if ( $file && ! empty( $file['path'] ) ) {

Expand Down
Loading