•  » Extensions
  •  » I've written a configurable Adult Content Notice plugin!

#1 2026-03-11 05:59:50

dan40
Member
2017-02-14
6

I've written a configurable Adult Content Notice plugin!

Hello/Hi/Greetings,

I tried using the existing Adult Content warning in the Plugins section, and found it doesn't work. So I enlisted the assistance of Gemini to help me write the code for a new Adult Content Warning message. Here is a breakdown of what it will do:

1. The Visitor Experience (Front-End)
When a new user lands on any page of your gallery, the plugin immediately triggers a full-screen "Frosted Glass" overlay.

Visual Obscuration: Instead of a simple black wall, it uses CSS backdrop-filter: blur(20px). This creates a sophisticated aesthetic where the gallery content is visible as abstract colors and shapes, but individual photos or text are impossible to make out.

Dynamic Dimming: The visitor sees a semi-transparent layer over the blur. The darkness of this layer is controlled by your "Opaqueness" setting, allowing the site's branding to bleed through or remain hidden.

Actionable Choices: The user is presented with two clear paths:

I Agree: Sets a browser cookie and instantly fades the overlay, granting access.

Exit Site: Redirects the user to a safe external URL (like Google) to ensure they aren't accidentally exposed to content.

2. The Administrator Experience (Back-End)
The plugin integrates directly into the Piwigo Administration panel, providing a dedicated settings page.

Live Configuration: You don't need to touch code to change the message. You can adjust the warning text, the redirect URL, and the "memory" of the plugin (how many days the cookie lasts).

Opaqueness Slider: A real-time slider (0-100%) allows you to dial in the perfect balance between a clear "glass" look and a solid, private background.

HTML Support: Unlike standard text fields, the message box accepts raw HTML. This allows you to embed logos, use custom fonts, or add links to your Terms of Service directly within the warning.

3. Technical Logic & Security
Cookie-Based Memory: The plugin uses a SameSite=Lax cookie. This is "privacy-first" logic—it remembers a user’s choice locally on their device so they aren't pestered with the warning every time they click a new photo, but it doesn't track them across the web.

Admin Immunity: It includes an IN_ADMIN check. This is a safety feature that ensures the warning only appears on the public-facing gallery. It will never pop up while you are working in the dashboard, preventing you from accidentally locking yourself out of your own settings.

Performance Optimized: The script is "injected" at the header level using Piwigo's native hook system. This means it starts loading before the images do, ensuring the content is obscured as quickly as possible.

4. Code Structure
The plugin is organized into three specific files:

main.inc.php: The "brain" that detects visitors and renders the overlay.

admin.php: The "bridge" that handles saving your settings to the database.

admin.tpl: The "face" of the settings page, designed to match the Piwigo dashboard.

If anyone wants a copy, please send me a private message or email me at dan.smith@shaw.ca. Eventually I'd like to figure out how to post this in the Plugins library, but I'm so new to this that it might take me a little time unless someone can tell me how to do this.

I'd love to hear from Adult content creators out there how this works for them.

Thanks,
Dan

Offline

 
  •  » Extensions
  •  » I've written a configurable Adult Content Notice plugin!

Board footer

Powered by FluxBB