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:
- Get All Images in Media Gallery?
- How to display .ico files in the media library
- List of available events for wp.media
- Uploading Images to Media Library via wp_handle_sideload() fails
- Bind event on Media gallery elements WordPress
- Add class=”media_type” when media is inserted into editor
- Migrating to HTTPS only, most media library links need updating?
- Failing to open advanced-cache.php which is breaking Media Library
- Remove the columns in media library
- How to save attachment data?
- How to enlarge thickbox media library iframe?
- How to modify Media Library images
- Inserting a Download Link in the Quick Edit Actions of the Media Library?
- How do I remove the entire Media section from the main WordPress navigation without just hiding it?
- Making the Add Media Link URL into a checkbox
- Add tab on new media library
- Is there any way to add images to the Media Library through a path on the server?
- Media Library page super slow, loading up full quality images
- How can I use the TinyMCE editor for the description field on a Media item?
- Share media among different domains
- How does the media library determine if a PDF file has preview images?
- resize from small images to large
- Bulk Import files on Media Library from CSV
- How can I make the Uploaded field editable for Media Library?
- “Insert Into Post” For Custom Button
- Display image file size in media library
- Media_handle_upload with custom upload folder?
- Remove the ‘Attachment Details’ section of the wordpress media manager
- remove_menu_page breaks “Add media”
- is there any hooks or action to fire function of insert into post in media library?
- Featured images get shrunken
- Organize media uploads in folders – I have a physical access to (my) server
- Pulling images from a subdomain
- Get image URL from media library “insert from url”
- Sorting Media Library by Author Name
- Media gallery: remove “insert into post” button keeping “Insert gallery” button
- Media Content disapeared after upgrade WP core to 3.5.1
- The best way to protect uploaded media in WordPress?
- change video icons to selected thumbnail?
- how to remove thumbnail and LiteSpeed Optimization column in media library list-view?
- How do I migrate blog post images from one domain to a new one?
- Manipulate an image before saving or after to the media libary
- wp_get_attachment_image_src returns the wrong image
- Media Library No Longer Displays Images
- Intersept image upload and generate retina image from source
- Crop image with full width
- Change Media Library thumbnails for non-image files to include the post title instead of the filename?
- attachment media-template data model (data.size.url)
- How do you alter the default WordPress thumbnail?
- Media Library, hook on delete user action
- Create a User Role with permissions to only upload files to the media library?
- Reorder attachements in the media library
- Adding Alt Tag Column to Media Library List
- High CPU load when loading images in media library
- How to modify the attachment info text on gallery tab or media page?
- Add media button always inserts media on the next wp_editor instance when created dynamically
- Images are displaying as blank images
- Media Library Latency, Lag, CRON?
- Is it Helpful to transfer all media library to another host? [closed]
- How to manage a music library in wordpress
- Media library on another server?
- Is there a way to determine if the media-iframe is visible?
- WordPress lowers image quality
- image not found in media library
- Windows Live Writer inconsistent with Media Library
- Is there a way to programmatically pass a category to the Media Library selector?
- Larger preview thumbnails in Media Library
- Media Library http to https
- Want to sell images online on wordpress but slow image loading issues
- How to limit the amount of images uploaded to the media library within post.php
- Change thumbnail size for Media Library
- Adding Facebook Open Graph Code does not work for Media Library Attachment Pages
- Update WP Media Library image unattended
- Media library corrupted after upgrading to 4.9.6
- Uploads folder only showing files up to the letter “P”
- query that alternates text posts with images from media gallery
- Can multiple sites under one folder structure share media directories?
- WordPress Media Delete Logs
- WordPress not using edited image
- How to display the date a directory folder on ftp was modified
- When I’m in post editor and click on ‘Add media’, why won’t it load the media library with this code?
- Create gallery doesn’t show uploaded images
- Media Library not showing images when adding to Posts (but retrieving image info via ajax)
- WordPress 3.5 Media Manager – Change loaded image Size [duplicate]
- How use Videos from another directory?
- Remove (Unattached) Attach from “Uploaded to” in Media Library
- Uploading pictures to the Media Library: “Specified file failed upload test.”
- Use the “Media Library” in Frontend
- Why is my upload / Select media library button empty?
- WordPress Media Library
- Create media library feed
- Broken image links in media library after restore
- Store images and videos category wise and fetch them in json format
- Add Filename Colum to Media Library
- create a user’s owned folder on user registration
- How to bulk edit taxonomies for attachments
- wp cli media commands not working
- Remove Edit Attachment Button in WordPress Mediathek -> see Screenshot
- in classic editor, is there a way to add media lib files to the content search when creating a link?
- Editing alt text in media library