Allow WebP screenshots (#503)

This commit is contained in:
Warr1024 2023-12-15 11:23:07 -05:00 committed by GitHub
parent c6a59701be
commit 0e5158704e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

@ -31,7 +31,7 @@ def do_create_screenshot(user: User, package: Package, title: str, file, is_cove
if count >= 20:
raise LogicError(429, lazy_gettext("Too many requests, please wait before trying again"))
uploaded_url, uploaded_path = upload_file(file, "image", lazy_gettext("a PNG or JPG image file"))
uploaded_url, uploaded_path = upload_file(file, "image", lazy_gettext("a PNG, JPEG, or WebP image file"))
counter = 1
for screenshot in package.screenshots.all():

@ -28,7 +28,7 @@ def get_extension(filename):
return filename.rsplit(".", 1)[1].lower() if "." in filename else None
ALLOWED_IMAGES = {"jpeg", "png"}
ALLOWED_IMAGES = {"jpeg", "png", "webp"}
def is_allowed_image(data):
@ -43,7 +43,7 @@ def upload_file(file, file_type, file_type_desc):
is_image = False
if file_type == "image":
allowed_extensions = ["jpg", "jpeg", "png"]
allowed_extensions = ["jpg", "jpeg", "png", "webp"]
is_image = True
elif file_type == "zip":
allowed_extensions = ["zip"]

@ -16,7 +16,7 @@
{{ form.hidden_tag() }}
{{ render_field(form.title) }}
{{ render_field(form.file_upload, fieldclass="form-control-file", accept="image/png,image/jpeg") }}
{{ render_field(form.file_upload, fieldclass="form-control-file", accept="image/png,image/jpeg,image/webp") }}
{{ render_submit_field(form.submit) }}
</form>
{% endblock %}

@ -12,7 +12,7 @@
{{ form.hidden_tag() }}
{{ render_field(form.title) }}
{{ render_field(form.file_upload, fieldclass="form-control-file", accept="image/png,image/jpeg") }}
{{ render_field(form.file_upload, fieldclass="form-control-file", accept="image/png,image/jpeg,image/webp") }}
{{ render_checkbox_field
{{ render_submit_field(form.submit) }}
</form>