mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-22 04:11:12 +00:00
Prevent images from downloading without consent
This commit is contained in:
parent
ce723776a5
commit
3cbe7e1efc
6 changed files with 44 additions and 40 deletions
|
@ -1 +1 @@
|
|||
Subproject commit e78c744abe5c3824f9ca7de7f1ee086468385ee0
|
||||
Subproject commit c88dd1e3b36ee1617f1b86acf94c1b7946e97cd4
|
|
@ -461,11 +461,3 @@ br.big {
|
|||
.totp-link {
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
#app[data-adult-consent] {
|
||||
filter: blur(10px);
|
||||
-webkit-filter: blur(10px);
|
||||
-moz-filter: blur(10px);
|
||||
-o-filter: blur(10px);
|
||||
-ms-filter: blur(10px);
|
||||
}
|
||||
|
|
|
@ -98,6 +98,16 @@ export async function createSsrHtml(
|
|||
${helmet.title.toString()}
|
||||
${helmet.meta.toString()}
|
||||
|
||||
<style>
|
||||
#app[data-adult-consent] {
|
||||
filter: blur(10px);
|
||||
-webkit-filter: blur(10px);
|
||||
-moz-filter: blur(10px);
|
||||
-o-filter: blur(10px);
|
||||
-ms-filter: blur(10px);
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Required meta tags -->
|
||||
<meta name="Description" content="Lemmy">
|
||||
<meta charset="utf-8">
|
||||
|
|
|
@ -40,7 +40,7 @@ export default class App extends Component<any, any> {
|
|||
id="app"
|
||||
className="lemmy-site"
|
||||
ref={this.rootRef}
|
||||
data-adult-consent={this.isoData.showAdultConsentModal}
|
||||
data-adult-consent={this.isoData.showAdultConsentModal || null}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
|
|
|
@ -89,8 +89,8 @@ interface AdultConsentModalState {
|
|||
|
||||
function handleAdultConsent(i: AdultConsentModal) {
|
||||
document.cookie = `${adultConsentCookieKey}=true; Path=/; SameSite=Strict${isHttps() ? "; Secure" : ""}`;
|
||||
document.querySelector("#app")?.removeAttribute("data-adult-consent");
|
||||
i.setState({ show: false });
|
||||
location.reload();
|
||||
}
|
||||
|
||||
function handleAdultConsentGoBack(i: AdultConsentModal) {
|
||||
|
|
|
@ -2,6 +2,8 @@ import classNames from "classnames";
|
|||
import { Component } from "inferno";
|
||||
|
||||
import { UserService } from "../../services";
|
||||
import { setIsoData } from "@utils/app";
|
||||
import { IsoData } from "../../interfaces";
|
||||
|
||||
const iconThumbnailSize = 96;
|
||||
const thumbnailSize = 256;
|
||||
|
@ -19,9 +21,7 @@ interface PictrsImageProps {
|
|||
}
|
||||
|
||||
export class PictrsImage extends Component<PictrsImageProps, any> {
|
||||
constructor(props: any, context: any) {
|
||||
super(props, context);
|
||||
}
|
||||
private readonly isoData: IsoData = setIsoData(this.context);
|
||||
|
||||
render() {
|
||||
const { src, icon, iconOverlay, banner, thumbnail, nsfw, pushup, cardTop } =
|
||||
|
@ -33,32 +33,34 @@ export class PictrsImage extends Component<PictrsImageProps, any> {
|
|||
true);
|
||||
|
||||
return (
|
||||
<picture>
|
||||
<source srcSet={this.src("webp")} type="image/webp" />
|
||||
<source srcSet={src} />
|
||||
<source srcSet={this.src("jpg")} type="image/jpeg" />
|
||||
<img
|
||||
src={src}
|
||||
alt={this.alt()}
|
||||
title={this.alt()}
|
||||
loading="lazy"
|
||||
className={classNames("overflow-hidden pictrs-image", {
|
||||
"img-fluid": !(icon || iconOverlay),
|
||||
banner,
|
||||
"thumbnail rounded object-fit-cover":
|
||||
thumbnail && !(icon || banner),
|
||||
"img-expanded slight-radius": !(thumbnail || icon),
|
||||
"img-blur": thumbnail && nsfw,
|
||||
"object-fit-cover img-icon me-1": icon,
|
||||
"img-blur-icon": icon && blurImage,
|
||||
"img-blur-thumb": thumbnail && blurImage,
|
||||
"ms-2 mb-0 rounded-circle object-fit-cover avatar-overlay":
|
||||
iconOverlay,
|
||||
"avatar-pushup": pushup,
|
||||
"card-img-top": cardTop,
|
||||
})}
|
||||
/>
|
||||
</picture>
|
||||
!this.isoData.showAdultConsentModal && (
|
||||
<picture>
|
||||
<source srcSet={this.src("webp")} type="image/webp" />
|
||||
<source srcSet={src} />
|
||||
<source srcSet={this.src("jpg")} type="image/jpeg" />
|
||||
<img
|
||||
src={src}
|
||||
alt={this.alt()}
|
||||
title={this.alt()}
|
||||
loading="lazy"
|
||||
className={classNames("overflow-hidden pictrs-image", {
|
||||
"img-fluid": !(icon || iconOverlay),
|
||||
banner,
|
||||
"thumbnail rounded object-fit-cover":
|
||||
thumbnail && !(icon || banner),
|
||||
"img-expanded slight-radius": !(thumbnail || icon),
|
||||
"img-blur": thumbnail && nsfw,
|
||||
"object-fit-cover img-icon me-1": icon,
|
||||
"img-blur-icon": icon && blurImage,
|
||||
"img-blur-thumb": thumbnail && blurImage,
|
||||
"ms-2 mb-0 rounded-circle object-fit-cover avatar-overlay":
|
||||
iconOverlay,
|
||||
"avatar-pushup": pushup,
|
||||
"card-img-top": cardTop,
|
||||
})}
|
||||
/>
|
||||
</picture>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue