Use BeEmbedMedia for custom object types extending Streams #960

fquffio opened this Issue Aug 30, 2016 · 2 comments


None yet

3 participants

fquffio commented Aug 30, 2016

If a custom object type extends BeditaStreamModel or BeditaSimpleStreamModel it is impossible to use BeEmbedMediaHelper to generate thumbnails and such.

We should add a configuration parameter to tell BeEmbedMediaHelper to treat a custom object type as if it was one of the core ones. For instance, one could have the Avatars object type, and want Avatars to behave like Images.

We could either add a global configuration (i.e. always handle Avatars as Images) or a per-invocation parameter {$beEmbedMedia->object($myObj, ['forceType' => 'Image', …])}… or both.

@bedita/core What's the best option?

@fquffio fquffio added this to the 3-stable milestone Aug 30, 2016
@fquffio fquffio self-assigned this Aug 30, 2016
batopa commented Aug 30, 2016 edited

Or we could define in the Model class how it behaves

class Avatar extends BeditaStreamModel {

    public function embedAs() {
         return 'Image';


than in BeEmbedMediaHelper we could change getType() method with something like

private function getType($obj) {
    $model = Configure::read('objectTypes.' . $obj['object_type_id'] . '.model');
    if (empty($model)) {
         return '';

    $objectModel = ClassRegistry::init($model)
    if (!method_exists('embedAs', $objectModel) {
        return $model;

    return $objectModel->embedAs();
fquffio commented Aug 30, 2016

Great idea! Probably I would also add $obj to embedAs method parameters, just in case the behavior depends on the object being embedded. Thus $objectModel->embedAs($obj).

@stefanorosanelli stefanorosanelli modified the milestone: 3-updates, 3-stable Aug 30, 2016
@stefanorosanelli stefanorosanelli modified the milestone: 3.8.0, 3-updates Oct 14, 2016
@batopa batopa closed this Oct 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment