Restrict file uploads by extension?

Is there a way in WordPress 3.1 to restrict allowed file uploads by extension (images only) and file size? Bonus question: Can I limit users to only be able view files they have uploaded themselves? 1 Answer 1 I believe you can add a filter to upload_mimes to restrict to certain types. The hook: … Read more

Why does SVG upload in Media Library fail if the file does not have an XML tag at the beginning?

I have enabled SVG uploads using this code: add_filter(‘upload_mimes’, function($mimes) { $mimes[‘svg’] = ‘image/svg+xml’; return $mimes; }); However, uploads of SVG files that start with the <svg> tag fail with the usual “Sorry, this file type is not permitted for security reasons.” error that WordPress displays when SVG uploads are not supported. If I add … Read more

Bulk Image Uploader to create new post from each image [closed]

Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for WordPress Development Stack Exchange. Closed 9 years ago. Improve this question Is there any plugin which creates a new post from each image I upload/select with it? I want to create many … Read more

Allow EPS file upload – two EPS files have different MIME types

I got this error message when trying to upload EPS-files to my WordPress Media Library: Sorry, this file type is not permitted for security reasons So I added this snippet to my functions.php add_filter( ‘upload_mimes’, function ( $mime_types ) { $mime_types[ ‘eps’ ] = ‘application/postscript’; return $mime_types; } ); After that I can upload several … Read more

Looks like image resize is not working well

Im searching for some clue about this behavior? I think it is a PHP memory_limit or WP define(‘WP_MEMORY_LIMIT’, ‘X’) issue? Sometimes images are resized and sometimes not, in other scenarios the browser crash: Im using Dreamhost as shared hosting, and their 7 upload limit. Error printed with an uploaded image of 6.4MB of size and … Read more

Why are two functions over-riding each other?

I have function in my plugin that is: add_filter(‘comment_text’, ‘commentimage_comment_text’); function commentimage_comment_text($comment=””) { $options = get_option(‘commentimage’); $id = get_comment_ID(); $images = $options[‘images’]; if (!isset($images) || !is_numeric($images)) $images = 1; $url = get_option(‘siteurl’); for ($i=0; $i<$images; $i++) { if (file_exists(ABSPATH . ‘wp-content/comment-image/’ . $id . ($i==0?”:(‘-‘.$i)) . ‘-tn.jpg’)) { $comment .= ‘<p><a href=”‘ . $url . … Read more