I probably wouldn’t add this to Media Cloud, mostly because I only add features my clients request or need for a given build.
However, you could add this to your plugin, fairly easily I think. Off the top of my head you’d have to:
- Detect if media cloud plugin was activated via
is_plugin_active('ilab-media-tools')
- The
\ILAB\MediaCloud\Tools\ToolsManager::instance() is the entry point into the plugin itself. You won’t have to include/require any files as it should autoload.
- Determine if cloud storage is enabled and activated by doing something like
\ILAB\MediaCloud\Tools\ToolsManager::instance()->toolEnabled('storage')
- If it’s enabled, you can get the storage interface via
\ILAB\MediaCloud\Tools\ToolsManager::instance()->tools['storage']
- Once you have the storage interface, you can copy a file to a new one and delete the old one. Refer to
classes/Cloud/Storage/StorageInterface.php for the method signatures, but it’d only be two calls.
- The data for storage is held in an array in an attachment’s meta (you can fetch with
wp_get_attachment_metadata($id) called s3. Use and update the values in that.
I think that’s all you’d have to do to get it working.
In theory 😉
-
This reply was modified 7 years, 8 months ago by
interfacelab.
-
This reply was modified 7 years, 8 months ago by
interfacelab.
Also, one thing to note is that you’d have to rename all the images size ONLY if Imgix wasn’t being used. If Imgix is enabled, the plugin disables any thumbnail generation that WordPress might do, relying on Imgix to do that. So, in that case, if Imgix is enabled you only have to rename a single file.
It looks like my reply is being held in moderation for some reason.
Do let me know if you implement this and I will add a blurb to the read me/plugin page about it.
Thanks!