Support » Plugin: Regenerate Thumbnails » Images replaced in posts all wrong

Viewing 8 replies - 1 through 8 (of 8 total)
  • We are experiencing this exact same issue with the latest update!

    Plugin Contributor Alex Mills

    (@viper007bond)

    Crap. Sorry about this.

    What is supposed to happen is my code searches for HTML like this, when you have the “update posts” checkbox checked (it is by default):

    
    <img class="aligncenter wp-image-46821 size-full" src="...
    

    With the number (46821) being the ID of the attachment it just updated. It then fetches the latest URL for that size (full, which in this case I should skip since it’s not a thumbnail) and updates the src value to the latest size.

    I thought I wrote rigorous test cases for this to make sure I didn’t have any bugs in the code but apparently that isn’t the case.

    By the way, did either of you happen to do any importing of content? I am now realizing that the attachment IDs in the post HTML versus the database might not align in that case.

    I think I’ll release v3.0.1 and disable this functionality until I can figure out what’s going wrong for you two.

    I can confirm the same problem. Yesterday I ran the module to update only the featured image for all posts. It took over four hours to run which I thought was odd because it was only about 1500 images. Today I discovered that every image on ten years worth of posts had been updated in what appears to be some random manner. Each post contains many copies of the same image, and its a different image from years prior.

    In case it helps, here’s a snippet of html from one of the pages.

    
    <a href="http://oliverands.com/community/content/uploads/2017/12/levine-interior.jpg"><img class="aligncenter size-large wp-image-63700" src="https://oliverands.com/community/content/uploads/2013/04/spring08-products-778489.gif" alt="Michael Levine LA" width="400" height="150" /></a>
    
    <a href="http://oliverands.com/community/content/uploads/2017/12/levine-african.jpg"><img class="aligncenter size-large wp-image-63701" src="https://oliverands.com/community/content/uploads/2013/04/spring08-products-778489.gif" alt="LA fabric shopping" width="400" height="150" /></a>
    
    <a href="http://oliverands.com/community/content/uploads/2017/12/levine-liberty.jpg"><img class="aligncenter size-large wp-image-63702" src="https://oliverands.com/community/content/uploads/2013/04/spring08-products-778489.gif" alt="LA fabric shopping" width="400" height="150" /></a>
    

    Same occurred to me yesterday at http://irachaleff.com

    Viper,
    I tried Regenerate Thumbnails after successive image imports failures.
    Hope this helps,
    Dario.

    Plugin Contributor Alex Mills

    (@viper007bond)

    @oliverands: For the first example, which is the correct image?

    http://oliverands.com/community/content/uploads/2017/12/levine-interior.jpg
    https://oliverands.com/community/content/uploads/2013/04/spring08-products-778489.gif

    I’m guessing the first one? If so, that’s a good thing as image ID 63700 is that one:

    https://oliverands.com/community/wp-json/wp/v2/media/63700

    That means the src value of the <img> tag can be updated to the correct thumbnail and it’s just a bug in my code that made it use the wrong image.

    If it’s the second one, then I’m guessing you did an import at some point? I realized after I released my plugin that the following situation could occur:

    1. Upload an image to site A. It gets the ID of 123.
    2. Insert the image into a post. The <img> tag includes wp-image-123.
    3. Content is exported from site A.
    4. Content is imported into site B that has existing content. Image gets the new ID of 456.
    5. Post still has 123 in it even though the image is now 456.

    This is assuming the importer doesn’t fix those IDs. I’ll have to check.

    You are right. It’s the first image that is correct. I’m glad it’s the better of the two cases!

    But there’s a second issue here too that you might want to check. I had clicked the button to only update the featured image on posts. I was expecting that this would update only the one featured image for each of my posts. But the module updated all images in all posts–not just the featured image.

    Thread Starter Lauren

    (@oncecoupled)

    I’m unsure on import status, but simply re-saving the post appears to fix the images.

    This might be a better way to get image IDs? https://wpscholar.com/blog/get-attachment-id-from-wp-image-url/. I haven’t really taken the time to think through that, but wanted to come with some suggestions vs. just problems. 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Images replaced in posts all wrong’ is closed to new replies.