• Resolved Jordy Meow

    (@tigroumeow)


    Hi,

    I am the developer of Media File Renamer and would love to see a “Rename” function in your plugin. Right now your plugin handles add, and delete, but many users rename files using my plugin and I would love to recommend them your plugin. Right now, I can’t ?? If you add it, I will definitely add support for your plugin in mine.

    Thanks ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author interfacelab

    (@interfacelab)

    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 6 years, 1 month ago by interfacelab.
    • This reply was modified 6 years, 1 month ago by interfacelab.
    Plugin Author interfacelab

    (@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.

    Plugin Author interfacelab

    (@interfacelab)

    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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Function to rename files’ is closed to new replies.