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

Rename UPLOADS folder with custom WP_CONTENT_DIR

After digging around, I ended up with using upload_dir filter. Here is what I tried in functions.php to change uploads to media. Hope it can help someone too 🙂 add_filter(‘upload_dir’, function($uploads) { $custom = []; foreach ($uploads as $key => $value) { if ( false !== strpos($value, ‘/app/uploads’) ) { $custom[$key] = str_replace(‘/app/uploads’, ‘/app/media’, $value); … 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

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