Skip to content

Commit

Permalink
Add folder name on top of video thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
burhandodhy committed Dec 13, 2024
1 parent b3e0d26 commit 3fb9aee
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
11 changes: 11 additions & 0 deletions assets/scss/components/_video-grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,14 @@
}

}

.brightcove__folder-name {
background: $grey;
bottom: 0;
color: $white;
left: 0;
padding: 3px 10px;
position: absolute;
text-align: left;
width: fit-content;
}
13 changes: 9 additions & 4 deletions includes/admin/class-bc-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ class="brightcove-datetime brightcove-end-date"
<span class="name"><?php esc_html_e( 'Folder', 'brightcove' ); ?></span>
<select class="brightcove-folder">
<option value="">None</option>
<# _.each(data.folders, function (folderName, folder_id) { #>
<# _.each(data.folders, function (folder, folder_id) { #>
<option value="{{ folder_id }}" <# if ( data.folder_id === folder_id ) { #>selected<# } #>>
{{ folderName }}
{{ folder.name }}
</option>
<# }); #>
</select>
Expand Down Expand Up @@ -672,6 +672,11 @@ class="brightcove-datetime brightcove-end-date"
<div class="duration">
<span>{{ data.duration }}</span>
</div>
<# if ( data.folder_id ) { #>
<div class="brightcove__folder-name brightcove__folder-name-{{data.folder_id}}">
{{ wpbc.preload.folders[data.folder_id]?.label || wpbc.preload.folders[data.folder_id]?.name }}
</div>
<# } #>
<# } #>
<# if ( data.video_ids ) { #>
<div class="video-count">
Expand Down Expand Up @@ -1261,9 +1266,9 @@ class="brightcove-datetime brightcove-end-date"
<label for="media-attachment-folders-filters" class="screen-reader-text"><?php esc_html_e( 'Filter by folder', 'brightcove' ); ?></label>
<select id="media-attachment-folders-filters" class="brightcove-media-folders attachment-filters">
<option value="all"><?php esc_html_e( 'All folders', 'brightcove' ); ?></option>
<# _.each(data.folders, function (folderName, folder_id) { #>
<# _.each(data.folders, function (folder, folder_id) { #>
<option value="{{ folder_id }}" <# if ( data.folder_id === folder_id ) { #>selected<# } #>>
{{ folderName }}
{{ folder.name }}
</option>
<# }); #>
</select>
Expand Down
31 changes: 13 additions & 18 deletions includes/api/class-bc-cms-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public function playlist_add( $name, $type = 'ACTIVATED_NEWEST_TO_OLDEST', $args
}

return $this->send_request( esc_url_raw( self::CMS_BASE_URL . $this->get_account_id() . '/playlists' ), 'JSON_POST', $data );

}

/**
Expand Down Expand Up @@ -112,7 +111,6 @@ public function playlist_count( $query = '' ) {
}

return false;

}

/**
Expand All @@ -131,7 +129,6 @@ public function playlist_delete( $playlist_id ) {
$playlist_id = sanitize_title_with_dashes( $playlist_id );

return $this->send_request( esc_url_raw( self::CMS_BASE_URL . $this->get_account_id() . '/playlists/' . $playlist_id ), 'DELETE' );

}

/**
Expand All @@ -150,7 +147,6 @@ public function playlist_get( $playlist_id ) {
$playlist_id = sanitize_title_with_dashes( $playlist_id );

return $this->send_request( esc_url_raw( self::CMS_BASE_URL . $this->get_account_id() . '/playlists/' . $playlist_id ) );

}

/**
Expand Down Expand Up @@ -183,7 +179,6 @@ public function playlist_list( $query = '' ) {
}

return $results;

}

/**
Expand Down Expand Up @@ -239,7 +234,6 @@ public function video_add( $name, $args = array() ) {
$data['name'] = utf8_uri_encode( sanitize_text_field( $name ) );

return $this->send_request( esc_url_raw( self::CMS_BASE_URL . $this->get_account_id() . '/videos' ), 'POST', $data );

}

/**
Expand All @@ -265,7 +259,6 @@ public function video_count( $filter = '' ) {
}

return false;

}

/**
Expand All @@ -284,7 +277,6 @@ public function video_delete( $video_id ) {
$video_id = sanitize_title_with_dashes( $video_id );

return $this->send_request( esc_url_raw( self::CMS_BASE_URL . $this->get_account_id() . '/videos/' . $video_id ), 'DELETE' );

}

/**
Expand Down Expand Up @@ -321,7 +313,6 @@ public function video_get_images( $video_id ) {
$video_id = sanitize_title_with_dashes( $video_id );

return $this->send_request( esc_url_raw( self::CMS_BASE_URL . $this->get_account_id() . '/videos/' . $video_id . '/images' ) );

}

/**
Expand All @@ -341,7 +332,6 @@ public function video_get_references( $video_id ) {
$video_id = sanitize_title_with_dashes( $video_id );

return $this->send_request( esc_url_raw( self::CMS_BASE_URL . $this->get_account_id() . '/videos/' . $video_id . '/references' ) );

}

/**
Expand All @@ -360,7 +350,6 @@ public function video_get_sources( $video_id ) {
$video_id = sanitize_title_with_dashes( $video_id );

return $this->send_request( esc_url_raw( self::CMS_BASE_URL . $this->get_account_id() . '/videos/' . $video_id . '/sources' ) );

}

/**
Expand Down Expand Up @@ -493,7 +482,6 @@ public function video_list(
}

return $results;

}

/**
Expand All @@ -516,7 +504,6 @@ public function video_update( $video_id, $args = array() ) {
$data = BC_Utility::sanitize_payload_args_recursive( $args );

return $this->send_request( esc_url_raw( self::CMS_BASE_URL . $this->get_account_id() . '/videos/' . $video_id ), 'PATCH', $data );

}

/**
Expand Down Expand Up @@ -775,7 +762,7 @@ public function remove_subscription( $subscription_id ) {
* @return array
*/
public function fetch_folders() {
$cache_key = 'BCFolders_' . $this->get_account_id();
$cache_key = sprintf( 'BCFolders_%s_%s', BRIGHTCOVE_VERSION, $this->get_account_id() );
$folders = get_transient( $cache_key );
$folders = false;
if ( false === $folders ) {
Expand All @@ -784,14 +771,23 @@ public function fetch_folders() {

if ( $request && ! is_wp_error( $request ) ) {
foreach ( $request as $folder ) {
$folders[ $folder['id'] ] = $folder['name'];
$folders[ $folder['id'] ] = [
'name' => $folder['name'],
];
}

set_transient( $cache_key, $folders, 600 );
}
}

return $folders;
/**
* Filter the videos folders.
*
* @since 2.8.8
*
* @param array $folders Array of folder ID and name.
* @param int $account_id The account ID.
*/
return apply_filters( 'brightcove_videos_folders', $folders, $this->get_account_id() );
}

/**
Expand Down Expand Up @@ -906,6 +902,5 @@ public function in_page_experiences_list( $query = '' ) {
}

return $results;

}
}

0 comments on commit 3fb9aee

Please sign in to comment.