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 {
|
.totp-link {
|
||||||
width: fit-content;
|
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.title.toString()}
|
||||||
${helmet.meta.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 -->
|
<!-- Required meta tags -->
|
||||||
<meta name="Description" content="Lemmy">
|
<meta name="Description" content="Lemmy">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
|
|
@ -40,7 +40,7 @@ export default class App extends Component<any, any> {
|
||||||
id="app"
|
id="app"
|
||||||
className="lemmy-site"
|
className="lemmy-site"
|
||||||
ref={this.rootRef}
|
ref={this.rootRef}
|
||||||
data-adult-consent={this.isoData.showAdultConsentModal}
|
data-adult-consent={this.isoData.showAdultConsentModal || null}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|
|
@ -89,8 +89,8 @@ interface AdultConsentModalState {
|
||||||
|
|
||||||
function handleAdultConsent(i: AdultConsentModal) {
|
function handleAdultConsent(i: AdultConsentModal) {
|
||||||
document.cookie = `${adultConsentCookieKey}=true; Path=/; SameSite=Strict${isHttps() ? "; Secure" : ""}`;
|
document.cookie = `${adultConsentCookieKey}=true; Path=/; SameSite=Strict${isHttps() ? "; Secure" : ""}`;
|
||||||
document.querySelector("#app")?.removeAttribute("data-adult-consent");
|
|
||||||
i.setState({ show: false });
|
i.setState({ show: false });
|
||||||
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAdultConsentGoBack(i: AdultConsentModal) {
|
function handleAdultConsentGoBack(i: AdultConsentModal) {
|
||||||
|
|
|
@ -2,6 +2,8 @@ import classNames from "classnames";
|
||||||
import { Component } from "inferno";
|
import { Component } from "inferno";
|
||||||
|
|
||||||
import { UserService } from "../../services";
|
import { UserService } from "../../services";
|
||||||
|
import { setIsoData } from "@utils/app";
|
||||||
|
import { IsoData } from "../../interfaces";
|
||||||
|
|
||||||
const iconThumbnailSize = 96;
|
const iconThumbnailSize = 96;
|
||||||
const thumbnailSize = 256;
|
const thumbnailSize = 256;
|
||||||
|
@ -19,9 +21,7 @@ interface PictrsImageProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PictrsImage extends Component<PictrsImageProps, any> {
|
export class PictrsImage extends Component<PictrsImageProps, any> {
|
||||||
constructor(props: any, context: any) {
|
private readonly isoData: IsoData = setIsoData(this.context);
|
||||||
super(props, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { src, icon, iconOverlay, banner, thumbnail, nsfw, pushup, cardTop } =
|
const { src, icon, iconOverlay, banner, thumbnail, nsfw, pushup, cardTop } =
|
||||||
|
@ -33,32 +33,34 @@ export class PictrsImage extends Component<PictrsImageProps, any> {
|
||||||
true);
|
true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<picture>
|
!this.isoData.showAdultConsentModal && (
|
||||||
<source srcSet={this.src("webp")} type="image/webp" />
|
<picture>
|
||||||
<source srcSet={src} />
|
<source srcSet={this.src("webp")} type="image/webp" />
|
||||||
<source srcSet={this.src("jpg")} type="image/jpeg" />
|
<source srcSet={src} />
|
||||||
<img
|
<source srcSet={this.src("jpg")} type="image/jpeg" />
|
||||||
src={src}
|
<img
|
||||||
alt={this.alt()}
|
src={src}
|
||||||
title={this.alt()}
|
alt={this.alt()}
|
||||||
loading="lazy"
|
title={this.alt()}
|
||||||
className={classNames("overflow-hidden pictrs-image", {
|
loading="lazy"
|
||||||
"img-fluid": !(icon || iconOverlay),
|
className={classNames("overflow-hidden pictrs-image", {
|
||||||
banner,
|
"img-fluid": !(icon || iconOverlay),
|
||||||
"thumbnail rounded object-fit-cover":
|
banner,
|
||||||
thumbnail && !(icon || banner),
|
"thumbnail rounded object-fit-cover":
|
||||||
"img-expanded slight-radius": !(thumbnail || icon),
|
thumbnail && !(icon || banner),
|
||||||
"img-blur": thumbnail && nsfw,
|
"img-expanded slight-radius": !(thumbnail || icon),
|
||||||
"object-fit-cover img-icon me-1": icon,
|
"img-blur": thumbnail && nsfw,
|
||||||
"img-blur-icon": icon && blurImage,
|
"object-fit-cover img-icon me-1": icon,
|
||||||
"img-blur-thumb": thumbnail && blurImage,
|
"img-blur-icon": icon && blurImage,
|
||||||
"ms-2 mb-0 rounded-circle object-fit-cover avatar-overlay":
|
"img-blur-thumb": thumbnail && blurImage,
|
||||||
iconOverlay,
|
"ms-2 mb-0 rounded-circle object-fit-cover avatar-overlay":
|
||||||
"avatar-pushup": pushup,
|
iconOverlay,
|
||||||
"card-img-top": cardTop,
|
"avatar-pushup": pushup,
|
||||||
})}
|
"card-img-top": cardTop,
|
||||||
/>
|
})}
|
||||||
</picture>
|
/>
|
||||||
|
</picture>
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue