is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’

Here’s something I wrote because my clients were using very high quality pngs, when they could be more lossy jpgs for web. Note this still preserves the original image, only changes the thumbnails. Add this to your functions.php <?php //Force PNG Thumbnails into JPGs add_filter(‘wp_generate_attachment_metadata’,’force_png_to_jpg’); function force_png_to_jpg($image_data) { $sizes = array(‘thumbnail’,’medium’,’large’); $upload_dir = wp_upload_dir(); $file … Read more

Using wp_handle_upload and media_handle_sideload with ajax

Uploading files in ajax is a bit tricky because it is not possible to upload files using the browser’s XMLHttpRequest object so you need to use some kind of Ajax upload plugin. Also wp_handle_upload() is not what your using in your code its media_handle_sideload() wp_handle_upload() – should be used for file uploads (input file field) … Read more

How to send email in wordpress with more than one attachments

Don’t know if that will solve all your problems, but: Generally nicely formatted code is easier to debug. E.g. your code is missing the closing brace. Besides it is better to write if/else(if) statements with braces. Nice indentation helps too. I’d suggest reading the WordPress – PHP Coding Standards. Regarding your code: As noted at … Read more

How to restrict wp-admin and prevent upload errors

You just need one extra thing for this. Here is the code I typically use to do what you are doing: function pws_block_admin() { if ( // Look for the presence of /wp-admin/ in the url stripos($_SERVER[‘REQUEST_URI’],’/wp-admin/’) !== false && // Allow calls to async-upload.php stripos($_SERVER[‘REQUEST_URI’],’async-upload.php’) === false && // Allow calls to admin-ajax.php stripos($_SERVER[‘REQUEST_URI’],’admin-ajax.php’) … Read more

How can I enable uploading excel files?

I think the proper filter would be mime_types found here. function wpse294198_mime_types( $mimes ) { $mimes[‘xls|xlsx’] = ‘application/vnd.ms-excel’; return $mimes; } add_filter( ‘mime_types’, ‘wpse294198_mime_types’ ); You can use command line tool file (linux|macOS) to see the mime type, e.g. file –mime-type -b somefile.xls

Frontend Post – Allow Only Image File Upload

You can check mime type of uploaded image before upload to media. Add mimeTypes in $allowmimeType which you want to allow. then check uploaded files mimetype $fileMimeType. If not found in allowed mimetype then return false. // Insert Attachment function insert_attachment($file_handler, $post_id, $setthumb=’false’) { if ($_FILES[$file_handler][‘error’] !== UPLOAD_ERR_OK){ return __return_false(); } # uploaded file type … Read more

Prevent renaming of uploaded media

“despite the fact that it’s just not necessary” I think you’d be surprised by how unnecessary looking stuff has a tendency of becoming absolutely necessary on some poorly configured servers. Else yes, it can be overridden using filters. You’re looking into overriding the stuff in sanitize_file_name(), which is located in wp-includes/formatting.php.

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