guardian / grid

The Guardian’s image management system
https://www.theguardian.com/info/developer-blog/2015/aug/12/open-sourcing-grid-image-service
Apache License 2.0
1.44k stars 119 forks source link

blur 'potentially graphic' images #4174

Closed twrichards closed 9 months ago

twrichards commented 9 months ago

With so many graphic images coming through as a result of the war, understandably there have been numerous requests for some mechanism to limit the effect on staff.

Preference is for blurring rather than filtering to avoid the chance of pictures being missed. Identifying graphic images is very challenging given the inconsistent ways the agencies flag such images... so this PR is to deliver the basic functionality sooner rather than later (to benefit Grid users), but we expect to further refine the criteria/heuristics for flagging such images.

Changes

Initially the 'potentially graphic image' detection was implemented via an ES Script Field (as this has access to the entire ES document, including all the original metadata where we hoping agencies would flag such images in a structured/consistent manner - alas, they do not). To aid with rapid iteration of the detection criteria/heuristics/logic the ability to control the 'painless' script was essential. There was a default, which could be overridden from the client (no build/deploy delay) via the value of a new cookie IS_POTENTIALLY_GRAPHIC_SCRIPT (on the parent domain, so media-api can see it).

We also chose to have this feature 'opt-in' (at least for now), which can be done via a checkbox in the menu in the top right...

image

... which sets a new SHOULD_BLUR_GRAPHIC_IMAGES cookie (on the parent domain, so media-api can see it).

After lots of experimentation with @paperboyo, we concluded we could actually identify the vast majority of such images by searching for a list of strings (words/phrases) within the description, title, special instructions and keywords - all of which is available in the media-api search response data - which meant this could be done purely client-side (thanks to @andrew-nowak for this nudge, after we struggled to get the OR logic working in the painless script). So I've removed the ability to edit the detection script from the client-side (via the IS_POTENTIALLY_GRAPHIC_SCRIPT cookie) but have added logic to the server-side to detect pur:adultContentWarning XMP field as we've observed this be used.

The actual blurring is achieved via simple CSS filter with some hover behaviour to reveal and a pseudo after element to add the explanation text... graphic_blur_off_by_default

In a follow-up PR, I'll look to make the list of strings configurable.

prout-bot commented 9 months ago

Seen on thrall, leases, kahuna, media-api (merged by @twrichards 8 minutes and 53 seconds ago) Please check your changes!

prout-bot commented 9 months ago

Seen on cropper (merged by @twrichards 9 minutes ago) Please check your changes!

prout-bot commented 9 months ago

Seen on auth, image-loader (merged by @twrichards 9 minutes and 4 seconds ago) Please check your changes!

prout-bot commented 9 months ago

Seen on metadata-editor, collections, usage (merged by @twrichards 9 minutes and 48 seconds ago) Please check your changes!