public function actionListMedia()
    {
        $result = array();

        if (isset($_GET['content_id']) && isset($_GET['content_type'])) {
            //get for modal
            $media = Media::find()
                ->leftJoin('kato_content_media', 'kato_content_media.media_id = kato_media.id')
                ->where(['kato_content_media.content_id' => $_GET['content_id'], 'kato_content_media.content_type' => $_GET['content_type']])
                ->all();
        } else {
            //return all media
            $media = Media::find()->all();
        }

        if ($media) {
            foreach ($media as $data) {
                $result[] = array(
                    'thumb' => '/' . $data->source,
                    'image' => '/' . $data->source,
                    'title' => '/' . $data->filename,
                    //'filelink' => '/' . $data->source,
                );
            }
        }

        echo Json::encode($result);
    }
public function actionListMedia()
    {
        $result = array();

        if (isset($_GET['content_id']) && isset($_GET['content_type'])) {
            //get for modal
            $media = Media::find()
                ->leftJoin('kato_content_media', 'kato_content_media.media_id = kato_media.id')
                ->where(['kato_content_media.content_id' => $_GET['content_id'], 'kato_content_media.content_type' => $_GET['content_type']])
                ->all();
        } else {
            //return all media
            $media = Media::find()->all();
        }

        if ($media) {
            foreach ($media as $data) {
                $result[] = array(
                    'thumb' => '/' . $data->source,
                    'image' => '/' . $data->source,
                    'title' => '/' . $data->filename,
                    //'filelink' => '/' . $data->source,
                );
            }
        }

        echo Json::encode($result);
    }
public function actionListMedia ( ) { $ result = array ( ) ; if ( isset ( $ _GET [ 'content_id' ] ) && isset ( $ _GET [ 'content_type' ] ) ) { //get for modal $ media = Media :: find ( ) -> leftJoin ( 'kato_content_media' , 'kato_content_media.media_id = kato_media.id' ) -> where ( [ 'kato_content_media.content_id' => $ _GET [ 'content_id' ] , 'kato_content_media.content_type' => $ _GET [ 'content_type' ] ] ) -> all ( ) ; } else { //return all media $ media = Media :: find ( ) -> all ( ) ; } if ( $ media ) { foreach ( $ media as $ data ) { $ result [ ] = array ( 'thumb' => '/' . $ data -> source , 'image' => '/' . $ data -> source , 'title' => '/' . $ data -> filename , //'filelink' => '/' . $data->source, ) ; } } echo Json :: encode ( $ result ) ; }
Returns list of media in json format
Returns list of media in json format