FIX: Replace links to removed uploads from reviewables with a placeholder (PR #10180)

The first commit ensures that the cook-text has a value set for the element field. This is needed to call the resolveAllShortUrls function.

The other two are trying to solve the main problem in two ways: one solution is entirely client-side and the other one is entirely server-side.

Client-side solution

It tries to resolve the short URLs as usual and when that fails because the upload is missing, it replaces the whole element with the placeholder.

Advantages:

  • Easy to implement and reason about.
  • It covers all the cases.
  • Does not alter the reviewables records.

Disadvantages

  • It can cause some flickering when the images are replaced with the placeholder.
  • The operation is not instant and some requests must be made before the client can decide if the image is indeed missing.

Server-side solution

It tries to replace the images with the short URLs with the placeholder in the job which deletes the upload records.

Advantages

  • The replacement happens only once and the result is saved.
  • Reduces the load (less requests) on the client-side.

Disadvantages

  • It searches for the upload in all reviewables.
  • Difficult to find all uses of the short URLs as there is no inverse HTML-to-Markdown map. Currently, it only covers the usual Markdown ![...](...).
  • Alters reviewable records.

GitHub

1 Like

Does that work on the server side? (eg. when cooking a post on the server via pretty-text)

I wonder, can we do that regexp search in SQL instead?

As of 7ddd83dfcf3a9d4328e0398f48347e1aba0bb922 the first commit is no longer required :slightly_smiling_face:

1 Like

Using a canvas to replace the image:

image

Any chances we could adapt these colors based on the current user theme colors?

Tiny but I would add a newline after the while and before that line.

Can we use the same font as the current theme?