Skip to content

Instantly share code, notes, and snippets.

@jeroendesloovere jeroendesloovere/README.md
Last active Mar 10, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.