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()
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
except KeyError as e:
@ -1782,7 +1782,7 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
db.session.commit()
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
if post.url:
@ -2002,7 +2002,7 @@ def update_post_from_activity(post: Post, request_json: dict):
db.session.commit()
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']:
post.nsfw = request_json['object']['sensitive']
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}"
db.session.commit()
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
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}"
db.session.commit()
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
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}"
db.session.commit()
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
if post.url:

View file

@ -345,7 +345,7 @@ def save_post(form, post: Post, type: str):
img_width = img.width
img_height = img.height
# 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)
thumbnail_width = img.width
thumbnail_height = img.height

View file

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

View file

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

View file

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