Create image formats with different qualities when uploading

1) A workaround by extending the WP_Image_Editor_GD class The problem is how to access the image sizes before we change the quality of intermediate jpeg images. Note that the image_resize() function is deprecated. We can use the jpeg_quality filter from the public get_quality method of the abstract WP_Image_Editor class: $quality = apply_filters( ‘jpeg_quality’, $quality, ‘image_resize’ … Read more

How can I batch delete all unattached images with WP-CLI or other automated process?

You can try this (untested) modification to the answer you linked to by @something wp post delete $(wp post list –post_type=”attachment” –format=ids –post_parent=0) to delete attachments without parents. To target a given mime type, e.g. image/jpeg try: wp post delete $(wp post list –post_type=”attachment” \ –format=ids –post_parent=0 –post_mime_type=”image/jpeg”) Notes: Remember to backup first before testing! … Read more

How to upload SVG in WordPress 4.9.8?

This question had me scratching my head. Yeah, how come WordPress doesn’t support this natively? And then I found out. You asked how to upload SVG in WordPress 4.9.8 (the current version at the time of writing). You mention that you “tried uploading after installing different plugins”. You don’t say which plugins, nor whether they … Read more

Media upload finished hook

it’s a longshot but, add_attachment hook, actually fires after the first file finished uploading: add_action(‘add_attachment’,’redirect_uploader_flow’); i’m using it to load a custom interface for resizing a Image loading in the current TB window: jQuery(“#TB_iframeContent”,window.parent.document).attr(‘src’,”<?php echo get_window_url($id) ?>”); the main problem is that it will break multiple file uploads

WordPress 3.5: Switch back to Old Media Uploader?

I just found this gem in WordPress forums, all props to A.Morita. Is there a way to disable the new Media Manager? Summing up all the code published, this is it: /** * I WANT THE OLD UPLOADER BACK * All code by: A.Morita * URL: http://wordpress.org/support/topic/is-there-a-way-to-disable-the-new-media-manager/ */ /** * Old upload Thickbox */ add_action( … Read more

Is it possible to reorganize the WordPress uploads directory?

Unfortunately that’s a very sad fact about WordPress, it provides almost no customization for the uploads in the back-end (except the y/m organization stuff) . What you can do, is to make your own custom class to generate the thumbnails (which are the most important part of performance impact, since every image generates a few … Read more

Set limit to media upload?

Yes, you can use the wp_handle_upload_prefilter that allows you to stop the uploading process if a specific condition is not accomplished. In your case, you could try this code snippet: function limit_upload_size( $file ) { // Set the desired file size limit $file_size_limit = 1024; // 1MB in KB // exclude admins if ( ! … Read more

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