• Resolved Matt Scheidler

    (@matt6303)


    We have used Participants Database for a school website for 6 school years. This is the beginning of the 7th year. When adding new teachers, the photos are being uploaded to an incorrect path.

    This is a WordPress multisite with multiple schools; we’re noticing this problem with the first school we’ve added new teachers to.

    In the plugin settings we have defined the File Upload Location:

    /wp-content/blogs.dir/5/files/participants-database/ (where 5 is the site ID in the multisite.)

    On the front end all of our teachers uploaded in previous years are showing up properly:
    https://schoolname.com/wp-content/blogs.dir/5/files/participants-database/firstname_lastname.jpg

    However, when I go to “Edit Existing Participant Record” in WordPress for one of those existing teachers, it shows “No File Chosen”.

    Conversely, the new teachers that are being added now, the images are not showing up in the front end. But on the “Edit Existing Participant Record” page, the photos are showing upon being uploaded, with this path:
    https://schoolname.com/bps/wp-content/blogs.dir/5/files/sites/5/participants-database/firstname_lastname.jpg

    To summarize, all the existing records are still good in the front end, even though they say “No File Chosen” in the back end. And all the new records return a broken image in the front end, but are visible in the back end.

    Other than the “File Upload” location as defined in the plugin settings, where is the actual location actively being used by the plugin defined? Somehow the plugin itself wants to place an additional “/sites/5/” into the path.

    I will be happy to provide further information to aid in troubleshooting. Thank you for your time.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author xnau webdesign

    (@xnau)

    Participants Database uses a single location for all uploaded images, so to get this all working, all your images need to be found at one path. I see at least two different paths that you mention in your question.

    If you are using some method other than Participants Database to upload the images, it very likely won’t work because those images will end up in a different location. If you stick with Participants Database to do the image uploads, then you won’t run into this problem.

    Since you do have your images in more that one place, you need to decide where you want them all to be, then make sure the “File Upload Location” setting is correctly pointing to that location.

    Then, you need to move the images that are not in that location to that location so that they are all in the same place. You won’t need to change the data in the records because image files are stored with no path information, it’s just the filename.

    Thread Starter Matt Scheidler

    (@matt6303)

    We are not doing anything different in 2018 to add new teachers and upload their photos, than we did in 2012 through 2017.

    Until today, all images have always been uploaded to /wp-content/blogs.dir/5/files/participants-database/, which has been, and continues to be, the location defined in the “File Upload Location” field in the plugin.

    Beginning this morning, images are being uploaded to /wp-content/blogs.dir/5/files/sites/5/participants-database/ – with an additional “/sites/5” included in the path.

    I cannot find /sites/5 (or better put, /sites/$blogid) anywhere. I’m not sure what is causing this behavior. The backend is uploading new files there, and also not finding the existing files because that’s not where they are.

    This is the first time we’ve needed to add new teachers since last August, so this problem actually might be up to 12 months old and we just hadn’t encountered it yet. We have not changed any plugin settings.

    Since posting my initial request I have continued troubleshooting and found the following, which is a separate but apparently related issue:

    All existing teachers are still displaying their photos on the front end, because their upload location and the file path in my PHP template match.

    All new teachers are not displaying their photos – even if I change the PHP template to point to their file path that includes /sites/5.

    The reason for this? There is some sort of rewrite happening. ALL of the teacher images on the front end show the following in the HTML: https://schoolname.com/wp-content/blogs.dir/5/files/participants-database/firstname_lastname.jpg – regardless of which of the two file paths I put into the PHP template.

    As a test I put two separate images in my template, one with the /5/files/ path and one with the /5/files/sites/5/ path. When the page is viewed, the existing teachers have their images displayed twice (/5/files/sites/5/ was rewritten to /5/files/ making both URLs the same) and the new teachers images were not displayed at all (with the rewrite, both URLs are the same and don’t match the image’s physical location on the server.)

    Temporarily I am getting around this problem by applying the following:

    1. Use PHP to determine if the file exists at /5/files/. If it does, I build the URL using that path and display it as always.

    2. If the file does not exist at /5/files/, I build the URL using a fake file path of /5/files/sites/5a . This is to prevent the rewrite from occurring (if I leave it as /5/files/sites/5 it is rewritten to just /5/files/).

    3. I’m then using a plugin to rewrite the incorrect path to /5/files/sites/5. This works because that plugin is set up to perform its rewrite after any other rewrites.

    As a result, I’m pulling images from two different directories, but regardless of where the image is uploaded, the template can find it and display it.

    Since a year has passed since our last successful update of teacher information, it is possible that an update to some other plugin has conflicted with yours. But I wanted to share this further information in the event that it might be similar to a previous issue you may have supported. Thanks again for your time.

    Plugin Author xnau webdesign

    (@xnau)

    I need to check into this further, but when the plugin is used in a multisite environment, it places the uploads for each site in a separate directory. That is where the “5” is coming from, the site ID is 5.

    Thread Starter Matt Scheidler

    (@matt6303)

    Thanks for the reply. At this point I’m not sure if the problem is a change to your plugin, or a change to someone else’s plugin that is affecting your plugin.

    The file upload location defined in the plugin settings has been the same since 2012.

    /wp-content/blogs.dir/5/files/participants-database/

    In 2012, 2013, 2014, 2015, 2016, and 2017, new photo uploads went to this path:

    https://schoolname.com/wp-content/blogs.dir/5/files/participants-database/firstname_lastname.jpg

    In 2018 the new photo uploads are going to this path:

    https://schoolname.com/wp-content/blogs.dir/5/files/sites/5/participants-database/firstname_lastname.jpg

    However, when that new path including /sites/5 is placed into the PHP template, it’s being rewritten back to the first path. Which isn’t where the JPG is.

    My solution with conditional code and rewriting a fake file path is working, so a “fix” isn’t imperative. Maybe someone else will encounter this issue, read this thread, and have their own idea on what’s going on. Thanks again for your time.

    Plugin Author xnau webdesign

    (@xnau)

    I tried to duplicate this issue on my test site, everything worked as expected.

    From the paths that you have posted here, I would guess you have some kind of plugin (or maybe theme) that is altering the media path for each site.

    Participants Database does it’s own alterations to the path so that each sub site stores it’s images in a different location.

    For example, if the File Upload Location setting for site 2 is the default ‘wp-content/uploads/participants-database/’ any files uploaded on that site will be placed in:

    ‘wp-content/uploads/sites/2/participants-database’

    So, participants Database adds the ‘sites/2’ part of the path. If the site ID is 3, it would be 3 instead of 2.

    I explain this so you can perhaps understand what is going on and what role some other plugin might be playing in determining that path.

    Participants Database recalculates the full path to the image when an image is displayed. If that path is getting altered by another plugin (or theme) then the resulting path could be incorrect.

    Thread Starter Matt Scheidler

    (@matt6303)

    Thank you for continuing to look into my situation.

    The last update you posted seems to shed some light on the situation.

    You say that your plugin does alter the File Upload location to add “/sites/2”. That’s exactly what’s been happening to my sites, but it never happened until this year. Is this a change to the plugin that was introduced sometime in the past 12 months?

    We had set up each of our sites in the multisite with a File Upload location where we already were specifying which site ID to upload the files to:

    /wp-content/blogs.dir/2/files/participants-database/

    That’s the path that the files were actually uploaded to in 2012 through 2017, and it’s the path I put into the PHP template.

    Now, in 2018, the files are being uploaded to:

    /wp-content/blogs.dir/2/files/sites/2/participants-database/

    That seems to match exactly with what you just described. The problem is that our site already had accounted for the different site IDs (we put the correct ID into the File Upload path for each site) and that the behavior is now different in 2018.

    Plugin Author xnau webdesign

    (@xnau)

    Your observations are correct, the plugin has only fully supported multisite for a little over a year, so it did start adding the site ID to the path to separate each site’s uploads. This is so the file uploads path setting wouldn’t have to be different for each site.

    Are you able to get things working by changing the file uploads path settings?

    Thread Starter Matt Scheidler

    (@matt6303)

    Thanks for continuing to look into this issue.

    My problem is that, we have 4 school websites in this multisite, and over 200 staff members in all. The update to your plugin that adds the Site ID to the path, doesn’t take into account that we were already adding the Site ID to the path.

    The options as I see them are to re-upload the photos for the 95% of teachers that were in the database prior to 2018 to match the 5% that were added this year, or to use the solution I applied to the PHP template last week that checks to see if the file is in the original location or not, and builds the image URL based upon that.

    Since the time is already invested in the workaround I think that’s where we’re going to leave things for now.

    Plugin Author xnau webdesign

    (@xnau)

    OK, I’m sorry the update had this effect, of course I was trying to make it work for everyone!

    Thread Starter Matt Scheidler

    (@matt6303)

    Thanks again for taking time to help me figure out definitively what was happening. Perhaps this thread can help someone else in my situation.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Photo being uploaded to incorrect path’ is closed to new replies.