Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of remote image/jpeg resources #9278

Merged
merged 1 commit into from
Dec 13, 2021

Conversation

jmooring
Copy link
Member

Closes #9275

@bep
Copy link
Member

bep commented Dec 12, 2021

I think it's better to add jpe to the MediaType configuration -- also, we should fix the "is not an Image" error message to display some information about what extension and MediaType Hugo guessed, so the user can fix this him/herself.

@jmooring
Copy link
Member Author

jmooring commented Dec 12, 2021

Yeah, I went back and forth on that. Instead of choosing the first extension from a somewhat arbitrary list that can vary from system to system, I thought it would be better to choose the "best" one, ensuring consistent builds across multiple systems.

// Ubuntu
mime.ExtensionsByType("image/jpeg") --> [.jpe .jpeg .jpg] 

// Windows 10
mime.ExtensionsByType("image/jpeg") --> [.jfif .jpe .jpeg .jpg] 

But I will make the change, adding both .jpe and .jfif.

Also, please see DM on forum.

@jmooring jmooring changed the title Set ext of image/jpeg files without ext to .jpg Add .jpe and .jfif to image/jpeg extensions Dec 12, 2021
@jmooring jmooring marked this pull request as draft December 12, 2021 20:15
".jpeg": JPEG,
".jpg": JPEG,
".png": PNG,
Copy link
Member

Choose a reason for hiding this comment

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

OK, I think I misunderstood the problem. I thought this was a "media type" problem. I see that there are some rooms for improvements in the above, but I suggest that you instead just do the mapping to jpg early (inside FromRemote).

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, we should also be able to process local files with .jpe and .jfif extensions, so I'll enable that. But yeah, with image/jpeg, it would nice to say "use the .jpg extension if an extension wasn't provided." So I'll do that too.

Copy link
Member

Choose a reason for hiding this comment

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

OK

Add jpe, jif, and jfif to image/jpeg extensions.
For remote image/jpeg without extension, always use jpg extension.

Closes gohugoio#9275
@jmooring jmooring changed the title Add .jpe and .jfif to image/jpeg extensions Improve handling of remote image/jpeg resources Dec 13, 2021
@jmooring jmooring marked this pull request as ready for review December 13, 2021 05:39
@bep bep merged commit a037be7 into gohugoio:master Dec 13, 2021
@jmooring jmooring deleted the iss9275 branch December 13, 2021 14:49
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remote image gets: *resources.genericResource is not an image
2 participants