Discourse Image Filter 🎴

This plugin uses the Google Cloud Vision API to restrict uploading explicit images to the forum. It accounts for all the images uploaded i.e. avatars, logos, etc.

It uses the upload error popup to display a message explaining which violations resulted in the restriction of the image upload.

The acceptable limits can be set via the site settings.


Setup

Steps:

  1. Create a service account on google cloud Creating and managing service accounts  |  Cloud IAM Documentation
    Google will trigger a download of a JSON file. Store its contents safely.

  2. Paste these lines at the bottom of env section in your app.yml

     GOOGLE_ACCOUNT_TYPE: 'service_account'
     GOOGLE_CLIENT_ID: 'client-id-from-json-file'
     GOOGLE_CLIENT_EMAIL: "service-account-email-address"
     GOOGLE_PRIVATE_KEY:  instructions below
    
  • How to setup GOOGLE_PRIVATE_KEY parameter?

    • Paste the key in the json file to code editor.
    • Use find and replace and replace \n with \\n
    • Copy the result and paste it in app.yml in front of GOOGLE_PRIVATE_KEY wrapping it in single quotes ' ' .
  1. Now follow the regular steps of installing the plugin.

Plugin Settings

if_adult_max_acceptable: Maximum acceptable level of the category adult
if_spoof_max_acceptable: Maximum acceptable level of the category spoof
if_medical_max_acceptable: Maximum acceptable level of the category medical
if_violence_max_acceptable: Maximum acceptable level of the category violence
if_racy_max_acceptable: Maximum acceptable level of the category racy

You can read about these criteria and the API itself in detail here. Detect explicit content (SafeSearch)  |  Cloud Vision API  |  Google Cloud

:page_facing_up: Get the code

:raising_hand_woman: Request a feature

:bug: Report a bug

Development Notes

For using in a dev environment on macos, add this line to your .bash_profile file
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

Lost?

Thanks @Terrapop for sponsoring the plugin.

3 Likes