Automatically assign video ‘poster’ value to ‘filename’ for archive listing

Thanks for your help. Managed to figure out a temporary solution, should anyone else have a similar query. Temporarily edited media.php $filename = basename( wp_get_attachment_url( $attachment_id ) ); $default_types = wp_get_video_extensions(); $defaults_atts = array( ‘src’ => ”, ‘poster’ => “diary/wp-content/Pictures/posters/”.$filename.”.jpg'”, ‘loop’ => ”, ‘autoplay’ => ”, ‘preload’ => ‘none’, ‘width’ => 640, ‘height’ => 360, … Read more

Restrict WordPress Media Library for a specific user role (users can only see/select own media)

add this to your functions.php or in a snippet, with this code the users with role external will only see their own uploads, any other role will see them all just has before. add_filter( ‘ajax_query_attachments_args’, ‘role_external’ ); function role_external( $query ) { $user_id = get_current_user_id(); if ( $user_id && current_user_can(‘external’) ) { $query[‘author’] = $user_id; … Read more

How can I create more upload paths, like a post corresponding to a post title folder used to store images of the same product

This probably isn’t the whole solution for you as you didn’t post any code, so I can’t incorporate what I know with anything, however, the following snippet will upload an image into a custom directory, made at the time of execution, as the attachment. I’ve commented the key lines… function upload_to_new_dir() { global $post; //This … Read more

How do I modify the “Insert Media” lightbox in the admin to only show media items from a category?

I think you can go about the filter list_terms_exclusions, but i don`t tested. example: function fb_list_terms_exclusions($args) { if ( ‘media-upload-popup’ != $where ) return $where; if ( !current_user_can(‘manage_categories’) ) $where = ” AND t.slug NOT IN (‘uncategorized’, ‘category-2’)”; // slug of categories return $where; } add_filter( ‘list_terms_exclusions’, ‘fb_list_terms_exclusions’ ); update for the comments to this … Read more

Pull images from the gallery

Use get_children() (Codex ref): $images = get_children( array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’ ) ); The first image will be $images[0]. EDIT: And by “first image”, I mean, the $ID of the first image, which you can use with any of the myriad image- and … Read more