nascentdigital / contentfully

A simple but performant REST client for Contentful.
MIT License
18 stars 7 forks source link

Add functionality to Media objects to leverage Contentful image APIs #32

Open sdedios opened 4 years ago

sdedios commented 4 years ago

Currently the Media objects used to represent assets from Contentful are plain Javascript objects without any functionality, however for certain media types (e.g. images) there exist rich Contentful APIs that provide transforms on the underlying image before serving it up to the client.

I would like to propose changing the Media interface / type to a class hierarchy that has additional functions which would support the broader image API features, such as:

This change would not break compatibility assuming we had a base interface for Media that still looks the same, but then had classes for specific media types such as ImageMedia that then implemented the interface. You could also just have a base class Media that was subclassed - these are minor implementation details.