# Discourse Image Filter

**URL:** <https://meta.discourse.org/t/discourse-image-filter/163927>\
**Category:** Plugin\
**Tags:** broken\
**Created:** [September 14, 2020, 6:54am UTC](https://meta.discourse.org/t/discourse-image-filter/163927 "2020-09-14T06:54:32Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)\
**Post date:** [September 14, 2020, 6:54am UTC](https://meta.discourse.org/t/discourse-image-filter/163927/1 "2020-09-14T06:54:32Z")

</div>

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 [Create service accounts &nbsp;|&nbsp; Identity and Access Management (IAM) &nbsp;|&nbsp; Google Cloud Documentation](https://cloud.google.com/iam/docs/creating-managing-service-accounts)  
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

- 
#### 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) &nbsp;|&nbsp; Cloud Vision API &nbsp;|&nbsp; Google Cloud Documentation](https://cloud.google.com/vision/docs/detecting-safe-search)

[📄 Get the code](https://github.com/paviliondev/discourse-image-filter)

[🙋‍♀️ Request a feature](https://thepavilion.io/w/feature-request)

[🐛 Report a bug](https://thepavilion.io/w/bug-report)

### 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?

- Not sure how to install a plugin? [Follow the steps here](https://meta.discourse.org/t/install-plugins-in-discourse/19157).  
  

Thanks @Terrapop for sponsoring the plugin.

---

_[View the full topic](https://meta.discourse.org/t/discourse-image-filter/163927)._
