bigger thumbnail files to match bigger display size #241

This commit is contained in:
rimu 2024-07-01 20:44:08 +08:00
parent a6b5e8d19a
commit 47dd776ca6
6 changed files with 10 additions and 10 deletions

View file

@ -912,7 +912,7 @@ def post_json_to_model(activity_log, post_json, user, community) -> Post:
db.session.commit() db.session.commit()
if post.image_id: if post.image_id:
make_image_sizes(post.image_id, 150, 512, 'posts') # the 512 sized image is for masonry view make_image_sizes(post.image_id, 170, 512, 'posts') # the 512 sized image is for masonry view
return post return post
except KeyError as e: except KeyError as e:
@ -1782,7 +1782,7 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
db.session.commit() db.session.commit()
if post.image_id: if post.image_id:
make_image_sizes(post.image_id, 150, 512, 'posts') # the 512 sized image is for masonry view make_image_sizes(post.image_id, 170, 512, 'posts') # the 512 sized image is for masonry view
# Update list of cross posts # Update list of cross posts
if post.url: if post.url:
@ -2002,7 +2002,7 @@ def update_post_from_activity(post: Post, request_json: dict):
db.session.commit() db.session.commit()
if post.image_id and post.image_id != old_image_id: if post.image_id and post.image_id != old_image_id:
make_image_sizes(post.image_id, 150, 512, 'posts') # the 512 sized image is for masonry view make_image_sizes(post.image_id, 170, 512, 'posts') # the 512 sized image is for masonry view
if 'sensitive' in request_json['object']: if 'sensitive' in request_json['object']:
post.nsfw = request_json['object']['sensitive'] post.nsfw = request_json['object']['sensitive']
if nsfl_in_title: if nsfl_in_title:

View file

@ -604,7 +604,7 @@ def add_image_post(actor):
post.ap_id = f"https://{current_app.config['SERVER_NAME']}/post/{post.id}" post.ap_id = f"https://{current_app.config['SERVER_NAME']}/post/{post.id}"
db.session.commit() db.session.commit()
if post.image_id and post.image.file_path is None: if post.image_id and post.image.file_path is None:
make_image_sizes(post.image_id, 150, 512, 'posts') # the 512 sized image is for masonry view make_image_sizes(post.image_id, 170, 512, 'posts') # the 512 sized image is for masonry view
# Update list of cross posts # Update list of cross posts
if post.url: if post.url:
@ -684,7 +684,7 @@ def add_link_post(actor):
post.ap_id = f"https://{current_app.config['SERVER_NAME']}/post/{post.id}" post.ap_id = f"https://{current_app.config['SERVER_NAME']}/post/{post.id}"
db.session.commit() db.session.commit()
if post.image_id and post.image.file_path is None: if post.image_id and post.image.file_path is None:
make_image_sizes(post.image_id, 150, 512, 'posts') # the 512 sized image is for masonry view make_image_sizes(post.image_id, 170, 512, 'posts') # the 512 sized image is for masonry view
# Update list of cross posts # Update list of cross posts
if post.url: if post.url:
@ -764,7 +764,7 @@ def add_video_post(actor):
post.ap_id = f"https://{current_app.config['SERVER_NAME']}/post/{post.id}" post.ap_id = f"https://{current_app.config['SERVER_NAME']}/post/{post.id}"
db.session.commit() db.session.commit()
if post.image_id and post.image.file_path is None: if post.image_id and post.image.file_path is None:
make_image_sizes(post.image_id, 150, 512, 'posts') # the 512 sized image is for masonry view make_image_sizes(post.image_id, 170, 512, 'posts') # the 512 sized image is for masonry view
# Update list of cross posts # Update list of cross posts
if post.url: if post.url:

View file

@ -345,7 +345,7 @@ def save_post(form, post: Post, type: str):
img_width = img.width img_width = img.width
img_height = img.height img_height = img.height
# save a second, smaller, version as a thumbnail # save a second, smaller, version as a thumbnail
img.thumbnail((150, 150)) img.thumbnail((170, 170))
img.save(final_place_thumbnail, format="WebP", quality=93) img.save(final_place_thumbnail, format="WebP", quality=93)
thumbnail_width = img.width thumbnail_width = img.width
thumbnail_height = img.height thumbnail_height = img.height

View file

@ -739,7 +739,7 @@ fieldset legend {
@media (min-width: 992px) { @media (min-width: 992px) {
.post_list .post_teaser .thumbnail img { .post_list .post_teaser .thumbnail img {
height: 90px; height: 90px;
width: 171px; width: 170px;
} }
} }
.post_list .post_teaser .thumbnail img.blur { .post_list .post_teaser .thumbnail img.blur {

View file

@ -332,7 +332,7 @@ html {
margin-left: 5px; margin-left: 5px;
@include breakpoint(tablet) { @include breakpoint(tablet) {
height: 90px; height: 90px;
width: 171px; width: 170px;
} }
&.blur { &.blur {
filter: blur(3px); filter: blur(3px);

View file

@ -902,7 +902,7 @@ def url_to_thumbnail_file(filename) -> File:
Image.MAX_IMAGE_PIXELS = 89478485 Image.MAX_IMAGE_PIXELS = 89478485
with Image.open(final_place) as img: with Image.open(final_place) as img:
img = ImageOps.exif_transpose(img) img = ImageOps.exif_transpose(img)
img.thumbnail((150, 150)) img.thumbnail((170, 170))
img.save(final_place) img.save(final_place)
thumbnail_width = img.width thumbnail_width = img.width
thumbnail_height = img.height thumbnail_height = img.height