Skip to content

Instantly share code, notes, and snippets.

@jeroendesloovere
Last active March 10, 2017 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeroendesloovere/c1c9b1313f818ddf2fb38f6858198852 to your computer and use it in GitHub Desktop.
Save jeroendesloovere/c1c9b1313f818ddf2fb38f6858198852 to your computer and use it in GitHub Desktop.
MediaLibrary + external Amazon, Dropbox, ...

Fork CMS MediaLibrary module + external storage type (Amazon, Dropbox, ...)

The idea

Backend thumbnails

What happens in the MediaLibrary module

When somebody uploads a source to the website. => A MediaItemCreated event is triggered.

Then the MediaItemListener listens to the MediaItemCreated Event and creates a Backend thumbnail. => A MediaItemBackendThumbnailCreated Event is dispatched.

Amazon MediaLibrary module

Then the AmazonMediaItemListener listens to the MediaItemBackendThumbnailCreated Event, moves the source- file over to Amazon and updates the MediaItem with the StorageType = External. Conclusion, the source is now on Amazon, the backend thumbnail remains local.

Frontend thumbnails

  • Source is now on Amazon
  • Backend thumbnail is local`

When the frontend wants an thumbnail, it triggers a FrontendMediaItemResolutionMissingEvent.

Then the MediaItemListener listens to the MediaItemCreated Event and creates a Frontend thumbnail. => A MediaItemFrontendThumbnailCreated Event is dispatched.

Amazon MediaLibrary module Then the AmazonMediaItemListener listens to the MediaItemFrontendThumbnailCreated Event, moves the frontend thumbnail- file over to Amazon.

Result: Every frontend thumbnail is now on Amazon.

ToDo: Frontend MediaItem

Now we need a way to let the MediaItem show the correct amazon frontend thumbnail or Source...

Ok, I got it. In the MediaItem I need to have a "class" that returns the webpath. By default the LocaleInterfacedClass returns the default webpath, but when the mediaItem is external, it should have the external path. Note: work with interface, f.e.

  • StorageProviderInterface
  • LocalStorageProvider implements StorageProviderInterface
  • ExternalStorageProvider implements StorageProviderInterface

ToDo: Think about deleting frontend thumbnails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment