We have a custom post type slugged 'download' and it acts like a posts but with the different slug. (It displays content like a post). Now, We have a custom field named "videos" and different videos are uploaded and attached in each posts of 'download'.
The video fields returns with an array https://prnt.sc/Hh9WtkKm8ZZa (This is ACF Gallery but we managed to display and attached videos in gallery field but we need to keep it array).
We wanted to get the file size of the videos uploaded in each post and display it in each post after post title of the downloads. (Single Post Page).
For example:
POST TITLE
*VIDEO1 * 68MB
*VIDEO2 * 100MB
*VIDEO3 * 200MB
The video attributes are saved and displays backend in the media page but we wanted to show it frontend after the video player. https://prnt.sc/Qf5M-V3rNHAp
To summarize, we wanted to get the all the video file size that is attached in the post. We also plan to sum all the attached video file for user doesn't need to view it 1 by 1.
//This is the code for the loop we are using to display videos.
//This works properly displaying video so dont mind the full size because we have also an image inside the loop.
if (!empty($custom_field_value)) {
$media_ids = explode(',', $custom_field_value);
foreach ($media_ids as $media_id) {
if (wp_attachment_is_image($media_id)) {
$image_display_size = $field_details['image_size'];
$display_image_url = $media_thumbnail_url = wp_get_attachment_image_src($media_id, $image_display_size);
$media_url = wp_get_attachment_image_src($media_id, 'full');
} else {
$media_url = wp_get_attachment_url($media_id);
}
if (wp_attachment_is_image($media_id)) {
?>