# Dynamic Cooper Filter Definitions: cooper-filter.json

`cooper-filter.json` is the source of truth for:

- Discover and Learn feed filter options.
- Subject Matter options offered when sharing an edit to the Community.
- "Popular Categories" listed at the bottom of Learn and Discover For You Feeds.
- Options offered in Tutorial Maker when submitting a tutorial.

## Consuming cooper-filter.json

You should compile `cooper-filter.json`, images from `cooper/images`, and optionally the translations*, into your app.  If we make a change here, your app build process should be able to simply sync down the changes and rebuild.  This will ensure all clients stay in sync as we make changes here.

*NOTE: Translations are currently in `lr-shared-files/cooper/cooper-loc/`.

### Top Level Keys

There are a set of objects in `cooper-filter.json` describing each feed filter list. They are identified by their top level keys:

| Key | Description |
| --- | ----------- |
| **learn_topics** | List of Learning Topics for the **Learn** feed  |
| **learn_tools** | List of Tools for the **Learn** feed |
| **learn_subject_matter** | List of Subject Matters for the **Learn** feed |
| **discover_subject_matter** | List of Subject Matters for the **Discover** feed |
| **learn_for_you_categories** | List of filter options shown at the bottom of the **Learn For You** feed |
| **discover_for_you_categories** | List of filter options shown at the bottom of the **Discover For You** feed |


### Anatomy of an entry

Each top-level object contains a set of objects.  The **key** for each object is the machine tag upon with you should search to display the feed, and the value contains data describing how it should be displayed.

Example of a list:

```
"discover_subject_matter": {
	"__all": {
		"title": "$$$/cooper/discover/filter/all=All",
		"position": 0,
		"image": "cooper/images/discover_subject_matter/all.jpg",
		"webpImage": "cooper/images-webp/discover_subject_matter/all.webp"
	},
	"sm:abstract": {
		"title": "$$$/cooper/discover/filter/abstract=Abstract",
		"image": "cooper/images/discover_subject_matter/abstract.jpg",
		"webpImage": "cooper/images-webp/discover_subject_matter/abstract.webp"
	},
	...
	"sm:black_and_white": {
		"title": "$$$/cooper/learn/filter/blackwhite=Black & White",
		"activeOption": false,
		"image": "cooper/images/learn_subject_matter/black_and_white.jpg",
		"webpImage": "cooper/images-webp/learn_subject_matter/black_and_white.webp"
	}
}

```
NOTE: `__all` is a special key, used to indicate no filter should be applied for that option.

NOTE 2: Currently, Lightroom Android uses Android recommended webp images and not jpg for filters. (more about webp here: https://developers.google.com/speed/webp)

Data for the entry is stored in key/value pairs as follows:

| key | required | description |
| --- | -------- | ----------- |
| **title** | required | The english zstring for the entry |
| **category** | required | Used for [deep links](https://wiki.corp.adobe.com/display/LrMobile/Deep+Linking%2C+App+Linking%2C+Universal+Linking%2C+UL%2C+AL) |
| **image** | *optional | absolute path to the image for this entry from the top of the repo |
| **position** | optional | **zero-based position at which this entry should be shown in the list  |
| **activeOption** | optional | ***Indicates that this option should not be shown. We use this to deprecate options but keep the string translations available. |

*Images, in general, should be provided.  Filters in learn_tools are an exception; they are shown without background images.

**All options without a position should be alphabetized in the current locale.

***Remember: Older discovers with deprecated machine-tags still need to be displayed to users, so we need the translations to stick around.

### Filter Image Requirements

Filter images are currently JPEG format and 300x300 pixels.

Clients are using images in the following way:

- Render the filter pill at no larger than 120x50.
- Scale the image to fit inside the width of the filter pill.
- Center-align the image vertically.
- Apply enough alpha that images containing white still have readable overlay text.
