There were two minor mistakes in my previous answer:
- I forgot to trigger the
change
event for the parent. - I called the function on every AJAX call, making other selections impossible.
Here is the fixed code:
<?php
/**
* Plugin Name: Pre-select post specific attachments
*/
add_action( 'admin_footer-post-new.php', 'wpse_76048_script' );
add_action( 'admin_footer-post.php', 'wpse_76048_script' );
function wpse_76048_script()
{
?>
<script>
jQuery(function($) {
var called = 0;
$('#wpcontent').ajaxStop(function() {
if ( 0 == called ) {
$('[value="uploaded"]').attr( 'selected', true ).parent().trigger('change');
called = 1;
}
});
});
</script>
<?php
}
Related Posts:
- How do I select an image from Media Library in my plugin?
- Media Library plugins for better file management? [closed]
- How to add subfolders in media library for better organisation?
- How to display .ico files in the media library
- print_media_templates not applied in media manager plugin
- Uploading Images to Media Library via wp_handle_sideload() fails
- image_size_names_choose filter doesn’t show
- Add class=”media_type” when media is inserted into editor
- How do I ‘rebuild’ the WordPress Media library after transfer to new host?
- Proper way to hook wp_get_attachment_url or any other way to change that url in media library
- How can I list URLs of all audio files within my media gallery?
- Migrating to HTTPS only, most media library links need updating?
- Failing to open advanced-cache.php which is breaking Media Library
- Filter pictures in the media library [closed]
- Is there a way to delete images from the Media Library programatically?
- Add file name column to media library
- Is there a way to specify the tab to display when the Media Uploader is displayed?
- How to add ‘Attachment Display Settings’ in custom Media Library?
- Image width tag is less than the image pixel width – why?
- Register an additional image size for only some images in my media library
- WordPress 3.5 Media Manager – Reorder Selectbox items on Media Library Tab [duplicate]
- Inserting a Download Link in the Quick Edit Actions of the Media Library?
- Change default screen option value for media items per page (in media library)
- Media Library page super slow, loading up full quality images
- Share media among different domains
- Where is the source of the media items filter
- how to download all media files into my computer
- Add image to media library from URL in uploads directory
- Function to get image from media library
- Adding Alt Attributes Automatically when Uploading Images to Media Library
- Media gallery thumbnails 1px
- How to have changes made in media library to be reflected on posts/pages
- Media_handle_upload with custom upload folder?
- Remove the ‘Attachment Details’ section of the wordpress media manager
- Why do I sometimes get an attachment id string instead of a url from an image’s guid field in the post table?
- How to change compression of WordPress uploads including original image
- Featured images get shrunken
- Pulling images from a subdomain
- Slow/Not Working Media Library Search
- wordpress not generate thumnails for mp4 videos
- Media Library not showing images properly
- Media Content disapeared after upgrade WP core to 3.5.1
- Clean up wp-content/upload/ folder
- The best way to protect uploaded media in WordPress?
- Media Library Grid View Custom Filter
- Not able to extend wp.media.view.AttachmentsBrowser
- Custom Media Modal and uploading
- Media Library No Longer Displays Images
- Media Library SSL
- Get the largest image based on a thumbnail in a URL
- WordPress does not detect all images in uploads folder?
- Media library and posts list problems with WordPress on IIS
- Can I set multiple feature images to multiple posts from the media library?
- How do you alter the default WordPress thumbnail?
- “add from media library” tab is super slow [closed]
- Reorder attachements in the media library
- Media library disallows spammy filenames?
- Recalibrate _wp_attachment_metadata Image Dimensions
- Adding Alt Tag Column to Media Library List
- Conditional tag to determine if the user is viewing the Add Media (after clicking Add media button)
- How to modify the attachment info text on gallery tab or media page?
- Adding Alt Tag and Dimensions columns to Media Library
- How can I delete duplicate `*-1.jpg` images?
- Extract url of every image in library?
- Media Library Latency, Lag, CRON?
- Is it possible to share WordPress media files among different domains?
- How to edit a deleted image gallery?
- Is there a way to determine if the media-iframe is visible?
- What would be the URL to display the WordPress image editor with an image from the media library?
- WordPress ACF delete image from media library
- Prevent other editors from viewing images of other editors in Add Media Popup
- Media attachment date and post date
- User media folder for each users on registration
- Larger preview thumbnails in Media Library
- WordPress Media Import, images not in Media Library
- How can I no-index specific PDF files in my Avada WordPress media library so that they don’t appear in search results?
- Media Library http to https
- Filter media library by custom postmeta
- How do you find a file in the media library using the file URL?
- How to limit the amount of images uploaded to the media library within post.php
- images inside wp-content/ uploads/ are not showing up in my media library and uploaded using FTP protocol
- add_image_size() in custom theme is not generating and saving any thumbnail
- Media library corrupted after upgrading to 4.9.6
- query that alternates text posts with images from media gallery
- Can multiple sites under one folder structure share media directories?
- WordPress Media Delete Logs
- When I’m in post editor and click on ‘Add media’, why won’t it load the media library with this code?
- how to setup user access media library?
- Get filenames of available image sizes
- Use the “Media Library” in Frontend
- Why is my upload / Select media library button empty?
- All the Images in Media Library is showing broken links
- Broken image links in media library after restore
- Add Filename Colum to Media Library
- create a user’s owned folder on user registration
- media library contains corrupt doubles
- How to bulk edit taxonomies for attachments
- Block non logged in users from accessing the media library
- Remove Edit Attachment Button in WordPress Mediathek -> see Screenshot
- Editing alt text in media library