Giter VIP home page Giter VIP logo

optimus's People

Contributors

coreykn avatar svenba avatar tg247 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

optimus's Issues

WebP files are not deleted when attachment is deleted

Problem

  • Website still consumes a very large amount of disk space after deleting media.

Cause

  • When deleting an attachment using WP-CLI (wp post delete --force 1234) then WordPress Core deletes its files from the uploads folder, but the webp files generated by Optimus remain in the filesystem.

Goal

  • Ensure webp derivatives are in sync with actual image attachments.
  • Free up disk space during cleanups to e.g. restart a site from scratch, or speed up website backup time.

Proposed solution

  1. React to the attachment delete hook.
  2. Check whether webp derivatives of registered image sizes exist in the filesystem.
  3. Delete the existing webp image files.

Notes

  • After fixing the basic integration behavior, a future PR could introduce a new WP-CLI command wp optimus webp delete-orphans similar to #7 that allows to clean up an existing filesystem (i.e., considering all the sites that have obsolete webp image files currently).

Create WP CLI command

Hello!

To optimize large installation the admin page can be really problematic for optimizing all the images.
Can you create a WPCLI command for optimizing one/all attachments ?
Like using the wp media regenerate command, we can have a wp media optimize or a wp optimus optimize :)

Pass _do_image_action public

Hello,

On some cases it can be usefull to call the optimus API for optimizing files from the filesystem.
For example here i'm using the "wpthumb" plugin for generating all the images sizes on the fly.

But this is not generating files for the webP only the png/jpg ones, but with only this lines of code :

<?php 
add_action( 'wpthumb_saved_cache_image', function( WP_Thumb $wpthumb ) {
	$file_path = $wpthumb->getCacheFilePath();
	Optimus_Request::_do_image_action($file_path, array(
            'file' => $wpthumb->getCacheFileURL(),
            'webp' => true
        ));
} );

I'm able to generate a webP version on the fly for our ressource, and with the right .htaccess rules the file is switched from png/jpg to the webP version :).

Is it possible to offer an API for optimizing any image file from the filesystem like the _do_image_action method can, because right now this is on private so unusable and duplicating all this code is not possible for us.

Rahe

CLI fetches ALL images from db, rather than the defined limit

This sql, fetches ALL images.
On sites with 100.000 images, this will properbly die.

$query = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->posts.post_mime_type
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->posts.post_type = 'attachment'
AND $wpdb->posts.post_mime_type LIKE 'image/%'
AND $queryImageTypes
AND $wpdb->postmeta.meta_key = '_wp_attachment_metadata'
AND $wpdb->postmeta.meta_value NOT LIKE '$optimus_query'
$id_query
ORDER BY $wpdb->posts.ID DESC";
return $wpdb->get_results($query, ARRAY_A);

We try to run some re-creating of .webp Images, but we suspect this one to be the root cause of why its not possible.

We do it via WP CLi, and the above sql, doesnt use LIMIT params, in order to listen on how many it should fetch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.