How to get media objects

Have you tried to use get_children() function? Edit: All media attached to any post is treated as children of it. The function wp_get_attachment_image() will only return images. With the function get_children() you’ll be able to get all the media, images or anything else. In the above link, you can find some examples.

Customizing default Mediaelement player

Okay so i did manage to add some custom css selectively on pages that load the medialement player by adding this to my functions.php file: function custom_player() { wp_enqueue_style( ‘custom-player’, get_stylesheet_directory_uri() . ‘/wp-mediaelement.css’ ); $custom_css = ” /*here goes the css*/ “; wp_add_inline_style( ‘custom-player’, $custom_css ); } add_action( ‘wp_enqueue_scripts’, ‘custom_player’ ); Like this by using … Read more

Add instructions For Media Library Uploads

Here are two examples using the pre-upload-ui and post-upload-ui hooks: add_action( ‘pre-upload-ui’, function() { ?><h4> <?php esc_html_e( ‘Please Remember This And That! (pre-upload-ui)’, ‘wpse’ );?> </h4> <?php }); add_action( ‘post-upload-ui’, function() { ?><h4> <?php esc_html_e( ‘Please Remember This And That! (post-upload-ui)’, ‘wpse’ );?> </h4> <?php }); You might want to adjust this further to follow … Read more

Get the path of the first attached media (single.php)

I tried to write some snippet with the help of WordPress codex. Please check below and update it further as per your needs. I hope this helps: global $post; $args = array( ‘numberposts’ => 1, ‘order’ => ‘ASC’, ‘post_mime_type’ => ‘image’, ‘post_parent’ => $post->ID, ‘post_status’ => null, ‘post_type’ => ‘attachment’, ); $attachments = get_children( $args … Read more

Find unused images?

Is there a reliable up-to-date way to find media that resides on the server but is not used in the WP site? In short: no, not as far as I’m aware. I have found a number of plugins, but all are very old, with lots of negative comments to the effect that they do not … Read more

Front end wp_editor not rendering audio/video links

I’ve been fighting this for a while on a series of themes I make that provide a front end content creation interface not requiring a WP account. For the last two years I have said “trust me, URLs will embed”. Those old tickets are dormant, but I just have found a solution here https://wordpress.stackexchange.com/a/287623 For … Read more