Skip to content

fix(assets): replace .gif asset format to webp for animated assets#3294

Open
SilberGecko6917 wants to merge 8 commits into
Pycord-Development:masterfrom
SilberGecko6917:fix/asset-extentions
Open

fix(assets): replace .gif asset format to webp for animated assets#3294
SilberGecko6917 wants to merge 8 commits into
Pycord-Development:masterfrom
SilberGecko6917:fix/asset-extentions

Conversation

@SilberGecko6917

@SilberGecko6917 SilberGecko6917 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR changes the .gif asset extention for avatars, banners and other images to the .webp extention.

https://docs.discord.com/developers/reference#image-formatting
image

I noticed that if a user had an animated profile picture, the URL of the image returned a 415 Unsupported Media Type error. 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

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).
  • I have read the Contributing Guidelines .

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.
  • AI Usage has been disclosed.
    • If AI has been used, I understand fully what the code does

@SilberGecko6917 SilberGecko6917 requested review from a team, Lulalaby and Lumabots July 2, 2026 13:27
@github-project-automation github-project-automation Bot moved this to Todo in Pycord Jul 2, 2026
@SilberGecko6917 SilberGecko6917 requested a review from a team as a code owner July 2, 2026 13:27
@pycord-app

pycord-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/3294/head:pr-3294
git checkout pr-3294

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3294/head

@SilberGecko6917 SilberGecko6917 requested a review from a team as a code owner July 2, 2026 13:29
@SilberGecko6917 SilberGecko6917 requested review from a team, Icebluewolf and JustaSqu1d July 2, 2026 13:29
Comment thread CHANGELOG.md Outdated
Comment thread CHANGELOG.md Outdated
Comment thread discord/asset.py Outdated

@Lulalaby Lulalaby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Paillat-dev

Copy link
Copy Markdown
Member

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.

@Paillat-dev Paillat-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wait for my review

@Paillat-dev Paillat-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread discord/asset.py
@@ -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))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

with_query replaces the entire query string rather than merging into it. See the discussion.

Suggested change
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

5 participants