Merge branch 'thumbnail-outsourced' of https://github.com/AndreVallestero/lemmy into AndreVallestero-thumbnail-outsourced
This commit is contained in:
commit
2719daffb0
2 changed files with 34 additions and 16 deletions
|
@ -198,8 +198,8 @@ fn fetch_iframely_and_pictshare_data(
|
||||||
Option<String>,
|
Option<String>,
|
||||||
) {
|
) {
|
||||||
// Fetch iframely data
|
// Fetch iframely data
|
||||||
let (iframely_title, iframely_description, iframely_thumbnail_url, iframely_html) = match url {
|
let (iframely_title, iframely_description, iframely_thumbnail_url, iframely_html) = match &url {
|
||||||
Some(url) => match fetch_iframely(&url) {
|
Some(url) => match fetch_iframely(url) {
|
||||||
Ok(res) => (res.title, res.description, res.thumbnail_url, res.html),
|
Ok(res) => (res.title, res.description, res.thumbnail_url, res.html),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("iframely err: {}", e);
|
error!("iframely err: {}", e);
|
||||||
|
@ -218,7 +218,18 @@ fn fetch_iframely_and_pictshare_data(
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
None => match url {
|
||||||
|
Some(url) => match fetch_pictshare(&url) {
|
||||||
|
// Try to generate a small thumbnail if iframely is not supported
|
||||||
|
Ok(res) => Some(res.url),
|
||||||
|
Err(e) => {
|
||||||
|
error!("pictshare err: {}", e);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
},
|
||||||
None => None,
|
None => None,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
33
ui/src/components/post-listing.tsx
vendored
33
ui/src/components/post-listing.tsx
vendored
|
@ -150,9 +150,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
let post = this.props.post;
|
let post = this.props.post;
|
||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
className={`img-fluid thumbnail rounded ${(post.nsfw ||
|
className={`img-fluid thumbnail rounded ${
|
||||||
post.community_nsfw) &&
|
(post.nsfw || post.community_nsfw) && 'img-blur'
|
||||||
'img-blur'}`}
|
}`}
|
||||||
src={src}
|
src={src}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -163,6 +163,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
if (isImage(post.url)) {
|
if (isImage(post.url)) {
|
||||||
if (post.url.includes('pictshare')) {
|
if (post.url.includes('pictshare')) {
|
||||||
return pictshareImage(post.url, thumbnail);
|
return pictshareImage(post.url, thumbnail);
|
||||||
|
} else if (post.thumbnail_url) {
|
||||||
|
return pictshareImage(post.thumbnail_url, thumbnail);
|
||||||
} else {
|
} else {
|
||||||
return post.url;
|
return post.url;
|
||||||
}
|
}
|
||||||
|
@ -542,8 +544,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
class={`icon icon-inline ${post.saved &&
|
class={`icon icon-inline ${
|
||||||
'text-warning'}`}
|
post.saved && 'text-warning'
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<use xlinkHref="#icon-star"></use>
|
<use xlinkHref="#icon-star"></use>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -586,8 +589,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
class={`icon icon-inline ${post.deleted &&
|
class={`icon icon-inline ${
|
||||||
'text-danger'}`}
|
post.deleted && 'text-danger'
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<use xlinkHref="#icon-trash"></use>
|
<use xlinkHref="#icon-trash"></use>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -618,8 +622,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
data-tippy-content={i18n.t('view_source')}
|
data-tippy-content={i18n.t('view_source')}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
class={`icon icon-inline ${this.state
|
class={`icon icon-inline ${
|
||||||
.viewSource && 'text-success'}`}
|
this.state.viewSource && 'text-success'
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<use xlinkHref="#icon-file-text"></use>
|
<use xlinkHref="#icon-file-text"></use>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -639,8 +644,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
class={`icon icon-inline ${post.locked &&
|
class={`icon icon-inline ${
|
||||||
'text-danger'}`}
|
post.locked && 'text-danger'
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<use xlinkHref="#icon-lock"></use>
|
<use xlinkHref="#icon-lock"></use>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -657,8 +663,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
class={`icon icon-inline ${post.stickied &&
|
class={`icon icon-inline ${
|
||||||
'text-success'}`}
|
post.stickied && 'text-success'
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<use xlinkHref="#icon-pin"></use>
|
<use xlinkHref="#icon-pin"></use>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Loading…
Reference in a new issue