Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Let gatsby-source-filesystem handle filenames #210

Merged
merged 1 commit into from
May 25, 2021

Conversation

damianstasik
Copy link
Contributor

I noticed that image assets generated with gatsby-source-strapi have two extensions in the filename: original and target extension.

Input: my_filename.jpg (original image is JPG)
Output: my_filename.jpg.png (when querying PNG image)

There were two solutions for this:

  1. Pass extension-less filename to name
  2. Let gatsby-source-filesystem handle the name and extension retrieval

I went with the second solution as gatsby-source-filesystem handles special characters (spaces, brackets, etc.) out of the box, but also adds additonal file hash to the filename for better cache invalidation.

@remidej
Copy link
Contributor

remidej commented May 24, 2021

Hello @visualfanatic, thanks for the PR

Input: my_filename.jpg (original image is JPG)
Output: my_filename.jpg.png (when querying PNG image)

I'm not sure what you mean when you say you're querying a JPG image as a PNG. Can you share a code snippet as an example?

Copy link
Contributor

@remidej remidej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even without the extension change question mentioned above, I could find the issue. When you fetch an image's absolute path, there is indeed an issue with double extensions (like image.png.png).

And now that I see the problem, I can confirm that this PR fixes it. Thanks!

@remidej remidej added this to the 1.0.1 milestone May 25, 2021
@remidej remidej merged commit 68d9c37 into gatsby-uc:master May 25, 2021
@damianstasik
Copy link
Contributor Author

@remidej sorry for the confusion, it should be webp instead of jpg. Gatsby converts webp to png when preparing the image to be used in gatsby-image/gatsby-plugin-image.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants