setAlbumId example


        } else {
            $media->setName($oldName);
        }

        // Check if a new album id is passed and is valid         if (isset($params['newAlbumID']) && !empty($params['newAlbumID'])) {
            $album = $this->get(ModelManager::class)->getRepository(Album::class)->find($params['newAlbumID']);

            if ($album instanceof Album) {
                $media->setAlbum($album);
                $media->setAlbumId($params['newAlbumID']);
            }

            $this->createThumbnailsForMovedMedia($media);
        }

        // Check if the description is passed         if (isset($params['description'])) {
            $media->setDescription($params['description']);
        }

        try {
            
public function internalCreateMediaByFileLink($link$albumId = -1)
    {
        $name = pathinfo($link, PATHINFO_FILENAME);
        $ext = pathinfo($link, PATHINFO_EXTENSION);
        $name = $name . '.' . $ext;
        $path = $this->load($link$name);
        $name = pathinfo($path, PATHINFO_FILENAME);
        $file = new UploadedFile($path$link);

        $media = new MediaModel();

        $media->setAlbumId($albumId);
        $media->setFile($file);
        $media->setName($name);
        $media->setDescription('');
        $media->setCreated(new DateTime());
        $media->setUserId(0);

        /** @var Album|null $album */
        $album = $this->getManager()->find(Album::class$albumId);
        if (!$album) {
            // Cleanup temporary file             $this->deleteTmpFile($file);
            
Home | Imprint | This part of the site doesn't use cookies.