Trigger JS when featured image upload window is opened in admin

After some digging I discovered that wp.media.featuredImage.frame() was what I was looking for: wp.media.featuredImage.frame().on(‘open’,function() { // Clever JS here }); I then discovered that the select event fires once you’ve clicked on the ‘Set featured image’ button, not when you’ve clicked on thumbnail, which was what I was after. So I bound my events to … Read more

Rename “Add Media” Button To “Add Images”

The button text being a translatable string, you can make use of the gettext filter: function wpse95025_rename_media_button( $translation, $text ) { if( is_admin() && ‘Add Media’ === $text ) { return ‘Add Images’; } return $translation; } add_filter( ‘gettext’, wpse95025_rename_media_button, 10, 2 ); For the sake of completeness: Of course, you can also keep the … Read more

Hook for image edit popup

The answer is there is no damn hook for the edit button. It’s just a bunch of JS contained within wp-includes/js/tinymce/plugins/wpeditimage/plugin.js. I’ve included the barebones of what you need below. Key points: a. Clicking an element with a data-wp-imgselect attribute will open the image edit dialogue. You need to change that to something else if … Read more

How to make WordPress use protocol indepentent upload files?

You can define a function to remove the protocol and hook it to the attachment URL: function wpse_79958_remove_protocol_from_attachment($url) { $url = str_replace(array(‘http:’, ‘https:’), ”, $url); return $url; } add_filter( ‘attachment_link’, ‘wpse_79958_remove_protocol_from_attachment’ ); Also consider to use relative URLs for attachments by using WordPress builtin function wp_make_link_relative: add_filter( ‘attachment_link’, ‘wp_make_link_relative’ ); Place this code to your … Read more

Media Uploader: get deleted files

Without seeing your “list editor” code I can only provide a theoretical answer. when a file is deleted in the media uploader, I also want it removed from the list the user is currently editing, so the files can’t be saved to my custom database table when it no longers exists in the “media environment”. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)