fix(assets): replace .gif asset format to webp for animated assets#3294
fix(assets): replace .gif asset format to webp for animated assets#3294SilberGecko6917 wants to merge 8 commits into
Conversation
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/3294/head:pr-3294
git checkout pr-3294This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3294/head |
|
I have the feeling that this PR is changing too much, but haven't had the time to take a look in depth. I will check it out asap. |
There was a problem hiding this comment.
Why was this added, as well as extension, as attributes ?
Adding size here seems kind of an unrelated change.
Please do something similar to 89cd452
Where a simple extension @\property was added with something like if self.animated ... else .... And default to webp for animated and png for not.
Also why did you add this:
if animated:
url += "&animated=true"
Independently of the reason, it again seems unrelated. Either change the scope of this PR or remove unrelated changes.
| @@ -467,7 +526,14 @@ def with_size(self, size: int, /) -> Asset: | |||
| raise InvalidArgument("size must be a power of 2 between 16 and 4096") | |||
|
|
|||
| url = str(yarl.URL(self._url).with_query(size=size)) | |||
There was a problem hiding this comment.
with_query replaces the entire query string rather than merging into it. See the discussion.
| url = str(yarl.URL(self._url).with_query(size=size)) | |
| url = yarl.URL(self._url).with_query(size=size) | |
| if self._animated: | |
| url = url.update_query(animated="true") | |
| url = str(url) |
Summary
This PR changes the
.gifasset extention for avatars, banners and other images to the.webpextention.https://docs.discord.com/developers/reference#image-formatting

I noticed that if a user had an animated profile picture, the URL of the image returned a
415 Unsupported Media Typeerror. For example, here:https://cdn.discordapp.com/guilds/1010915072694046794/users/851762178532311050/avatars/a_8a63bc5a3a227954876eb04778006c13.gif?size=1024
but with webp it works:
https://cdn.discordapp.com/guilds/1010915072694046794/users/851762178532311050/avatars/a_8a63bc5a3a227954876eb04778006c13.webp?animated=true&size=1024
I used claude (https://claude.ai/) to check over my code and get some help with how i could fix the issue.
Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.