# Rebaking posts does not fix broken locally downloaded linked images

**URL:** https://meta.discourse.org/t/rebaking-posts-does-not-fix-broken-locally-downloaded-linked-images/98470
**Category:** Support
**Created:** [October 1, 2018, 12:37pm UTC](https://meta.discourse.org/t/rebaking-posts-does-not-fix-broken-locally-downloaded-linked-images/98470 "2018-10-01T12:37:13Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![marcozambi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcozambi/32/119505_2.png) [@marcozambi](https://meta.discourse.org/u/marcozambi)
#### Post date: [October 1, 2018, 12:37pm UTC](https://meta.discourse.org/t/rebaking-posts-does-not-fix-broken-locally-downloaded-linked-images/98470/1 "2018-10-01T12:37:13Z")

</div>

Not entirely sure this is a bug, still…

My situation is the following:

- I imported an old SMF2 website in Discourse. Some of the posts had a lot of images linked, and in order to avoid loosing them in the future if links are broken, I enabled the “download remote images to local” feature in Discourse settings.
- A few downloads of such images failed, as the NASA server were not available at the moment of the image retrieval, leaving the baked version of that post with broken links to images (i.e. showing the “chain” square symbol), as well as the raw version of the post still showing the link to the original source.
- The problem with the source server was temporary, as if I edit the post with broken images I can clearly see them in the WYSIWYG area to the right hand side of the composer, and also because I can open the links to the images just copy/pasting their URL in a different tab of the browser, and they do work perfectly.
- If I save and rebake the post, the problem is not solved, and the links remain broken.

This is one of the broken images

 ![](https://global.discourse-cdn.com/meta/original/3X/e/e/ee507e1a7022cdf850513e01fb89795a9800f4af.jpeg)

So I thought that there must have been a reason why the rebake was failing to retrieve now available linked images, I mean a place where this “broken link” information was stored, and I found that in table post\_custom\_fields.  
I found out that all the pictures the rebake process was unable to retrieve were present in records in this table, specifically records having column name = ‘broken\_images’.  
If these records were deleted manually from the PostgreSQL database, then those posts rebaked, I was able to finally have the images back (although sometimes more than one try was necessary).

This is a good workaround, but risky, as I don’t feel safe manually hacking the database.

Wouldn’t make a lot more sense if the rebake process could delete all the entries where name = ‘broken\_images’ related to a rebaking post?

Or am I missing something obvious?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 2, 2018, 1:33am UTC](https://meta.discourse.org/t/rebaking-posts-does-not-fix-broken-locally-downloaded-linked-images/98470/2 "2018-10-02T01:33:25Z")

</div>

> [@marcozambi](#):
>
> Wouldn’t make a lot more sense if the rebake process could delete all the entries where name = ‘broken\_images’ related to a rebaking post?

I agree with this, hard caching image is broken forever is a bit too strict here, at a minimum we should expire that information after N days.

I think rebakes should try again for sure.

@vinothkannans what are your thoughts here?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [October 2, 2018, 2:09am UTC](https://meta.discourse.org/t/rebaking-posts-does-not-fix-broken-locally-downloaded-linked-images/98470/3 "2018-10-02T02:09:29Z")

</div>

I agree, rebake should retry to download all broken images.

> [@sam](#):
>
> hard caching image is broken forever is a bit too strict here, at a minimum we should expire that information after N days.

I think it’s not needed after we implemented the both “retry on rebake” and “[retry broken images N times in X hours](https://meta.discourse.org/t/image-downloader-should-be-more-resilient-to-download-failures/94883/12)” features. We can extend the X hours to 1, 10, 24, 72, 168.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [October 2, 2018, 3:56am UTC](https://meta.discourse.org/t/rebaking-posts-does-not-fix-broken-locally-downloaded-linked-images/98470/5 "2018-10-02T03:56:50Z")

</div>

Is redownload broken going to be a job we can manually trigger?

Will there be an upper limit on the number of attempts?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [October 2, 2018, 5:09am UTC](https://meta.discourse.org/t/rebaking-posts-does-not-fix-broken-locally-downloaded-linked-images/98470/6 "2018-10-02T05:09:01Z")

</div>

In future you need to rebake / “Rebuild HTML” to retry broken images download. It won’t have any upper limit.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [January 2, 2019, 2:24pm UTC](https://meta.discourse.org/t/rebaking-posts-does-not-fix-broken-locally-downloaded-linked-images/98470/8 "2019-01-02T14:24:11Z")

</div>

This is already done as per commit below

[https://github.com/discourse/discourse/commit/2b006c0429e25d25b9cae6bf95fe9d98f3f8b55d](https://github.com/discourse/discourse/commit/2b006c0429e25d25b9cae6bf95fe9d98f3f8b55d)

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [September 6, 2019, 12:21pm UTC](https://meta.discourse.org/t/rebaking-posts-does-not-fix-broken-locally-downloaded-linked-images/98470/9 "2019-09-06T12:21:20Z")

</div>


