Insert module and image derivatives

Created on 5 February 2016, over 9 years ago
Updated 14 January 2025, 7 months ago

s3fs has some inconsistent behavior with the Insert module.

After reading through https://www.drupal.org/node/2339067 β†’ , I believe I understand why, but I'm not sure if this is a bug or a support request.

To reproduce:

  1. Add an image field and configure it to use the Insert module (the core "Article" content type will work for this)
  2. Create a new node
  3. Upload an image to the image field
  4. Select an image style (e.g., large) and click "Insert" to insert the HTML code for an image into the body field
  5. The HTML code inserted is <img src="/s3/files/styles/large/public/filename.jpg?itok=4-l6mjxh" (i.e., the callback to _s3fs_image_style_deliver())
  6. Save the node
  7. See that the code for the image is in the Body field is <img src="/s3/files/styles/large/public/filename.jpg?itok=4-l6mjxh"
  8. Edit the node
  9. Select the same image style and click "Insert" to insert the HTML code for an image into the body field
  10. The HTML code inserted is <img src="https://name-of-s3-bucket.s3-aws-region.amazonaws.com/s3fs-public/styles/large/public/filename.jpg?itok=4-l6mjxh" (i.e., the direct link to the asset on S3).
  11. Save the node
  12. See that the code for the second image is in the Body field is <img src="https://name-of-s3-bucket.s3-aws-region.amazonaws.com/s3fs-public/styles/large/public/filename.jpg?itok=4-l6mjxh"

Like I said, after reading through https://www.drupal.org/node/2339067 β†’ , I think the reason that this happens is that on the first pass, the Insert module makes a call to s3fs's stream wrapper, which says, "I don't have that derivative; the URL is /s3/files/styles/large...".

On the second pass, s3fs's stream wrapper says, "I have that derivative; the URL is [direct link to file on S3]"

This gets complicated in a couple of ways:

  1. The overhead of continuing to call _s3fs_image_style_deliver() for the first image, even after the derivative exists.
  2. If the image derivative goes away (e.g., drush image-flush --all), and the HTML is pointing directly at S3, you have broken image links in your HTML.

I'm not sure what the solution is here. It may just be a limitation in the interaction between the two modules. But I didn't see anything posted in the issue queue of either module, so I wanted to at least point it out.

πŸ’¬ Support request
Status

Closed: outdated

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States John Bickar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States cmlara

    Drupal 7 end-of-life triage:
    Drupal 7 reached end of life on January 5th.

    The 7.x branches of S3FS do not have any additional planned releases.

    The requests in this issue do not appear to be S3FS module and instead relate to the Insert module.

    Long term I do not believe we can solve this inside S3FS, we have no way to know why a URL is requested.

    There is some talk in other issues that AWS buckets could possibly do server side processing, however that would be limited to Amazon only.

Production build 0.71.5 2024