New answers tagged

1

I found the problem :) Actually this is my friend's website. I don't have any idea how he changed the upload dir but I noticed that there is no define( 'UPLOADS', ''.'uploads' ); in his wp-config.php file. I added it and it's now working perfectly. I hope this helps other people who will facing this problem.


0

The reason for the media uploader not opening when clicking the second button is that both of your buttons have the same ID, which you are also binding to the function that open your uploader. Element IDs should always be unique, hence the .click function listener will only detect when user clicks the first button (=first one with id="image-url"). To solve ...


-2

In below code we find out mime type of uploaded file. Then using switch case we check mime type of uploaded file is application/pdf or not. $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $_FILES['file']['tmp_name']); $ok = false; switch ($mime) { case 'application/pdf'; $ok = true; default: die("Unknown/not ...


0

The solution is actually very simple, it's just one line of code, since i realized that attachment id is actually same as any other post id i can retrieve user id based on post field. $post_author_id = get_post_field( 'post_author', $post_id ); This gets the user id of the user who uploaded image and $post_id is image attachment id So further checking ...


0

I am using something similar in my website, to only show media attachements uploaded by other users, if this is an option for you, you can use the code or you can edit it to match your need but the truth is that it gets the user ID in the same way it would get it from a post with post_author Here's the code you can test it and see if this will work good for ...


0

Most likely, all you need to do is add this to your theme's functions.php file. However, you should also be aware that if you didn't create this theme and you update it, these modifications will be overridden. You can apply them again, but a better method for this (as I've explained a bit more in this answer) is to create a child theme. Alternatively, if ...


2

Embarrassing. $(mediaUploader).on('select', function(){ Should be: mediaUploader.on('select', function(){ In case anybody stumbles upon this, $({item}) looks for the item in the DOM, not the variable of the same name in the previous code. Since the select event isn't firing in the DOM, the callback function isn't going to fire either.


0

You mentioned simple solution, but I am not certain there would be anything simple in it I will make a research about it and update my answer if I get any results, but for now I can only give a recommendations. The problem is that you could delete the entry from the database fairly easy, but I don't think it would be possible to handle the file itself. Use ...


0

You would need to do a SELECT statement against the wp_posts and wp_users tables to get a list of all file names that qualify. Then manually delete them in the uploads folder. If it's on a Linux server I would create a BASH script to remove them all at once.


2

When you create an attachment, do the following: If attachments parent ID is for a post with an excluded post type, do nothing If it isn't in the list of excluded post types, assign it a tag in a hidden custom taxonomy e.g. function create_hidden_taxonomy() { register_taxonomy( 'hidden_taxonomy', 'attachment', array( ...


2

Media items are just like posts with post_type = attachment and post_status = inherit. when we are on upload.php page, we have two views: List View Grid View Grid view is populated via JavaScript and list view is extending normal WP_List_Table. Since it (List view) is using normal post query we can use pre_get_posts to alter the query to hide required ...


2

WordPress has some standard images thumbnail,medium,medium_large,large for which image sizes you can set it under Settings --> Media except medium_large size whose default height set to 768px ( medium_large is available from WP4.4). So when you set 0 to in the media settings it won't generate thumbnail,medium size,large size images and it didn't as far ...


0

Here is a similar question. The simplest solution that worked for me was use the upload_dir filter. Place the code below in your functions.php file. function wpcb_upload_dir_filter($uploads){ $day = date('d'); $uploads['path'] .= '/' . $day; $uploads['url'] .= '/' . $day; return $uploads; } add_filter('upload_dir', 'wpcb_upload_dir_filter')...



Top 50 recent answers are included