Site logo

[Resolved] deleted image file keeps being referenced in the site-logo div

Home Forums Support [Resolved] deleted image file keeps being referenced in the site-logo div

Home Forums Support deleted image file keeps being referenced in the site-logo div

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1911194
    Cleo

    The src= path keeps retaining a logo that has been deleted from the media library. srcset= path references the correct logo and its retina variation. The correct logo shows up on the site but google tools shows an error when it gets a 404 for the missing graphic. I deleted and re-added the correct logo via customizer to every place I could think it might appear (Site Identity (logo and retina), Site Icon and Sticky Navigation).

    Am I missing something? How can I purge this non-existent file from the homepage code that is generated?

    Here’s the code: note if you try to go to the site-logo src file (https://www.largelyunattended.com/wp-content/uploads/2021/08/OWN-BW-site-logo-500.png) you will get a page not found.

    <div class="site-logo">
    		<a href="https://www.largelyunattended.com/" title="OysterWeekNH" rel="home">
    			<img class="header-image is-logo-image" alt="OysterWeekNH" src="https://www.largelyunattended.com/wp-content/uploads/2021/08/OWN-BW-site-logo-500.png" title="OysterWeekNH" srcset="https://www.largelyunattended.com/wp-content/uploads/2021/08/OWN-BW-site-logo-500.png 1x, https://www.largelyunattended.com/wp-content/uploads/2021/08/OWNH-logo-500.png 2x" width="500" height="299">
    		</a>
    </div>
    #1911512
    David
    Staff
    Customer Support

    Hi there,

    can you try the following:

    1. Rename your original logo image(s), so its not the same as the previous.
    2. Reupload the new logo file.
    3. Replace the Site Identity logos with you renamed file(s).

    #1911596
    Cleo

    There’s more to the story. I actually did exactly as you described above – “permanently deleted” all instances of the logo from the Media library. Renamed the original logo (OWN-BW-site-logo-500.png) to OWNH-logo.png, uploaded it to the Media Library, and added it via Customizer as the site identity logo for both Logo and Retina.

    The “more to the story” is that I went to the server and noticed variations of the old logo still appeared in the /uploads/ folder (cropped- and a few size alternatives that were auto-generated). I guess Media Library’s “delete permanently” didn’t catch these. So, I deleted every instance and variation I could find of the original logo from the server. I just checked that folder again and don’t see anything with the name or variation on the name of the original logo – yet the original logo path still appears when I view the html with Dev Tools.

    Is this bad practice – going to the server directly to delete image files that weren’t “deleted permanently” through the media library? Might this confuse the database? BTW, I haven’t touched the database (had some presence of mind not to do great damage).

    Since I already did the steps that you described I’m reluctant to do it again – though it might be interesting to see how many new ghost images files end up in the html. Is there some other cached place that WordPress might still be finding the name of non-existent files?

    This isn’t a show-stopper (unless the 404 files are messing with SEO), I’m more curious to understand best practices for changing artwork and not ending up with a lot of dead files on the server, or 404 links in the generated html.

    #1911619
    David
    Staff
    Customer Support

    There are instances where WP caches an image URL – hence different filenames for replacement images is the best course of action. Deleting stuff from the database, generally its a last resort, but sometimes necessary.

    However, if the images in the Site Identity have been updated to new files with new names, then the HTML should regenerate to reflect that.

    So, do you have any functions in place that are changing the behaviour of the logo ?

    #1911869
    Cleo

    I haven’t made additions to the functions.php file (do have some commented-out code for randomizing archive page elements).
    Plugins are minimal – All-in-One WP Migration, GP Premium, Posts in Sidebar, The Events Calendar, and WP Forms.

    I think I found the source of the problem – not the cause.

    I created a banner in Elements and experimented with different things, added the logo, deleted the logo, added a background image. The final state of the banner was just text over a background image (no logo). However, somehow the old logo is still being added to the HTML.

    To test this, I verified that the Display Rules in Elements was set to display the banner on the Front Page, and, that is where the old logo appears in the div class site-logo code. I checked the About page which didn’t have the banner, and there is no reference to the old logo anywhere. Then, I changed the Display Rules to only show the banner on the About page. The old logo appeared in the HTML on the About page but was no longer in the HTML on the Frontpage.

    I suspect when I added the old logo to the banner in an early version of its design, the name never got completely removed. If it would be helpful, I could do a more thorough re-play of all of this. It would eat up some time, so let me know if you think it’s worth it. What I would do is create a new Header Element – add a logo, remove the logo, delete the logo and see if it’s still in the Elements Header code under site-logo div.

    #1912511
    David
    Staff
    Customer Support

    Ahh… so does the Header Element ( that had the Logo ) still exist ?

    #1912708
    Cleo

    Yes, the header element still exists.

    I created a new header just like the original. Now I have two Header Elements – the original and identical-looking new one.

    The new header has no issues. When I display the old header on a page, the non-existent logo code always shows up.

    It seems like adding a logo and later removing it while designing a header preserves the file name in the site-logo div. I don’t know how you purge it – other than deleting the header and rebuilding it.

    This reference to a non-existing logo doesn’t even show up as an error in Google Dev Tools, but it is a link on the site to a file that is not found. I’m sure there are much bigger fires to fight – but it could be a rainy day backlog item.

    #1913714
    David
    Staff
    Customer Support

    If you add a new logo to the header element, and then remove that logo, does that fix the issue ?
    Or worst case delete that header element and create a new replacement.

    #1913824
    Cleo

    Hi David,

    In this case, the solution was to delete the header and start over. I tried reproducing the problem by creating new headers with logos and deleting them. I didn’t have any problems with ghost links being retained. I may have gotten into some weird state where the deleted logo just couldn’t be cleared from that particular header.

    There may be issues with how all that is handled but it’s so low a priority, I don’t think anyone needs to spend a minute on it. If it comes up again, I will document how it happened.

    Thanks for all your time on this. I’d mark it solved.

    Cleo

    #1913874
    David
    Staff
    Customer Support

    Thank you for taking the time to test and provide feedback.
    We’ll keep an eye out for the issue re-occurring.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.