Why is wp_get_attachment_image_src not working with my custom size (add_image_size)
Does the 48×48 thumbnail file exist? If not, you can use a plugin like Regenerate Thumbnails.
Does the 48×48 thumbnail file exist? If not, you can use a plugin like Regenerate Thumbnails.
Actually you can, and here’s how to do it: This code hides all posts and media that do not belong to the currently logged in author (you can change it to apply to other user roles). It also fixes the post and media count on the filter bars (e.g. All | Images | Videos | … Read more
Code based on Custom Sortable Columns add_filter(‘manage_upload_columns’, ‘size_column_register’); function size_column_register($columns) { $columns[‘dimensions’] = ‘Dimensions’; return $columns; } add_action(‘manage_media_custom_column’, ‘size_column_display’, 10, 2); function size_column_display($column_name, $post_id) { if( ‘dimensions’ != $column_name || !wp_attachment_is_image($post_id)) return; list($url, $width, $height) = wp_get_attachment_image_src($post_id, ‘full’); echo esc_html(“{$width}×{$height}”); }
I am not sure is this what you are looking for. This code will “lock” uploads to show only “Uploaded to this post” in media panel add_action( ‘admin_footer-post-new.php’, ‘firmasite_mediapanel_lock_uploaded’ ); add_action( ‘admin_footer-post.php’, ‘firmasite_mediapanel_lock_uploaded’ ); function firmasite_mediapanel_lock_uploaded() { ?> <script type=”text/javascript”> jQuery(document).on(“DOMNodeInserted”, function(){ // Lock uploads to “Uploaded to this post” jQuery(‘select.attachment-filters [value=”uploaded”]’).attr( ‘selected’, true ).parent().trigger(‘change’); … Read more
Might wanna look at https://developer.wordpress.org/reference/functions/wp_upload_dir/ In definition there is a hook upload_dir, you can use that to change path. Haven’t tried or tested it, but you can give it a try.
As mentioned in a comment, media is actually a special ‘post’, so the media only belongs to the sub-site, and is not easily accessible from the subsite. But there are methods to go though all subsites and display the media from all subsites on a single page in any subsite. I do this with my … Read more
You are close, you just need to hook into the add event instead of the reset event. (In case you did not know, these are standard events provided by Backbone collections. So familiarizing yourself with that will be helpful when developing things around stuff where WordPress employs Backbone.js.) So basically you’d modify your code like … Read more
You can use pre_get_posts to filter the query. So you can retrieve a category from query vars the retrieve the post with that category set the media query to include only post having that posts as parent To give an UI you can use restrict_manage_posts hook to output a category dropdown. add_action(‘pre_get_posts’, ‘my_filter_media_by_cat’); add_action( ‘restrict_manage_posts’, … Read more
(function ($) { “use strict”; $(function () { var button = $(‘.upload-image’); button.click(function (e) { e.preventDefault(); // If the media frame already exists, reopen it. if (file_frame) { file_frame.open(); return; } var btn = $(this), media = wp.media; // Create the media frame. var file_frame = media.frames.file_frame = media({ title: jQuery(this).data(‘uploader_title’), button: { text: jQuery(this).data(‘uploader_button_text’) … Read more
You cannot do a sort on the attachment meta data specifically because it’s stored in a serialized string. Whilst WP_Query can sort on meta values it can’t sort on data that’s serialized. For example wp_get_attachment_metadata fetches and unserializes that for you inside the column callback, but MySQL queries can’t sort on that type of data. … Read more