• Hi Alan

    I’m doing following:
    1. Adding an image via WP Media Library (it is added to uploads/2018/08)
    2. Checking for new folders or pressing Sync in folder uploads/2018 to get folder 08 listed in Media Library Folders
    3. Having to press Sync to show added image in folder 08
    4. Moving the image to folder uploads/test

    Following problems occur:
    – As soon as Sync is pressed (step 3), a duplicate of the image is created in the DB (why is pressing Sync even necessary?)
    – As soon as the image is moved (step 4), the original attachment DB entry points to a non-existing path
    – In case of having the image already added to a gallery, the gallery points to the non-existing path
    – Minor: The guid in the DB of the moved image is a local file-system specific path. However, the post-meta entry is fine.

    The problem does not occur when the folder is already shown in the Media Library Folder plugin and I add a 2nd image.

    The problem occurs again when I delete the 08 mgmlp_media_folder entry in the DB and repeat step 1 to 4.

    I’m wondering if you are able to reproduce this issue?

    Best regards
    Christian

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author AlanP57

    (@alanp57)

    In order for Media Library Folders to work properly, new folders have to be added to the database before performing file operations. Media Library Folders tries to check for new folders, every hour, when the plugin is used. If you wish to insure that the folder tree is up to date, click the Check for New Folders options at the beginning of each month.

    Thread Starter Christian Frick

    (@christian-frick)

    Hi Alan

    IMO is having to check for new folders not really a proper solution. That’s why I spent some time and adapted your plugin a bit. I will send you the adapted file by email.

    Here’s what I changed:
    * When uploading an attachment to a folder which is not yet indexed by your plugin, it automatically adds the related folder recursively in an efficient way
    * When performing a sync and finding an attachment which is already indexed by the Media Library but not your plugin, it only indexes it by your plugin but don’t generate a duplicate
    * When moving an attachment on a Windows server, the guid is properly updated

    Please let me know if you understand my adaptions and if they are fine for you. I would love to see them in a future release.

    Best regards
    Christian

    Plugin Author AlanP57

    (@alanp57)

    I’ll take a loot at it. Perviously MLF use wp_cron to check for new folders. However I found that this was not functioning universally on all WordPress sites. Earlier this year we replace it code to check for new folder whenever the MLF pages was opened and to rechecked on an hourly basis. We could institute the wp_cron again for cases when MFL page is not used.

    Thread Starter Christian Frick

    (@christian-frick)

    Those approaches are all quite brute force and inefficient. The one I choose is quite simple:
    When an attachment is added, the path of the attachment is figured out, it is checked if the folder is already indexed, if not, it is recrusively added.

    Your implementation has an issue at this specific part anyway: you assume that all attachments are always added to the default folder resp. the current month. This is afaik not the case: When adding an attachment to an older post resp. gallery, it is added to the months folder of the post, which could be an older one. The approach above does fix this issue.

    Cheers, Christian

    Plugin Author AlanP57

    (@alanp57)

    Yes, according to your opinion. But your approach of checking if the folder is registered in the database before saving can work once I can add the missing functions. Then I can include it in the next release.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Moving images of non-index folders fails’ is closed to new replies.