WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
[resolved] Deleting host server file shows blank image in media library (6 posts)

  1. kg
    Member
    Posted 3 years ago #

    Hiya,

    I use this plugin primarily to free up local (not CDN) host server space.

    Therefore, I delete local images after CDN upload. And I realise that I have to put something together to automate this manual process.

    1) Perhaps, add a setting that enables WP media library page to use CDN hosted images.

    2) Is there a meta value that holds the status of the image, e.g. Exists at CDN, Exists at CDN and Locally, Exists locally, Null = Not found. This could create the foundations for improved management of files.

    3) I see (as example) the hook into wp_generate_attachment_metadata has no priority, and another plugin I know of uses this hook too. I'm not sure which will run first (race condition?) and this is an area for concern.

    What do you think?

    Thanks in advance,
    kg

  2. kg
    Member
    Posted 3 years ago #

    Further,

    I created a hook for w3tc_cdn_add_attachment, where I remove certain files from being uploaded to CDN.

    There is now a situation where $files can be empty, and this will create an error down in Rscf.php at line 110 due to an empty array passed in.

    Therefore, for succesfull use of the w3tc hooks, I added a tweak to the upload function in w3-total-cache/lib/W3/Plugin/Cdn.php

    @set_time_limit($this->_config->get_integer('timelimit.cdn_upload'));

    // kg: exit if no files are available to process
    if(empty($files)) return true;

    if (!$cdn->upload($files, $results, $force_rewrite)) {

    ---

    Hope this helps others.

    kg

  3. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    I'm sorry, I'm not going to support this use case. Feel free to modify the plugin as you see fit, or find a more competitive host with greater disk space. This disk space is a non-issue among top tier hosts for the past couple years, not to mention multiple if not at least one backup of files is something I encourage.

  4. kg
    Member
    Posted 3 years ago #

    "I'm sorry, I'm not going to support this use case."

    You miss the point. Where your hook filter is utilised, then the array can be passed back as empty, therefore, the solution I submit will prevent future headaches for anyone implmementing the hook and passing back an empty array. Plus it is only one line!

  5. prattmic
    Member
    Posted 3 years ago #

    kg, I am interested in doing something similar to what you have done, that is removing files from the host server after they have been uploaded. Is the one line edit you have provided all I need to be able to delete the files without breaking everything? Also, have you set up some kind of automated system to delete newly uploaded files, or do you do that manually.

    Thanks

  6. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    Ok, thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic