method updateContent documentation in bbn\Appui\Medias
Updates the content of the media when it's deleted and replaced in the bbn-upload
function(string $id_media, int $ref, string $oldName, string $newName, string $title)
{
$tmp_path = Mvc::getUserTmpPath().$ref.'/'.$oldName;
$new_media = [];
if ($this->fs->isFile($tmp_path)) {
$file_content = file_get_contents($tmp_path);
if (($media = $this->getMedia($id_media, true))) {
$old_path = $media['file'];
$full_path = $this->getMediaPath($id_media, $newName);
if ($this->fs->putContents($full_path, $file_content)) {
if ($this->isImage($full_path)) {
$thumbs_sizes = $this->getThumbsSizes($media);
$image = new Image($full_path);
$this->removeThumbs($old_path);
$image->thumbs(X::dirname($full_path), $thumbs_sizes, '.bbn-%s', true);
$media['is_image'] = true;
}
}
if($this->updateDb(
$id_media, $newName, $title, [
'path' => $media['path'],
'size' => $this->fs->filesize($full_path),
'extension' => X::pathinfo($full_path, PATHINFO_EXTENSION)
]
)
) {
$new_media = $this->getMedia($id_media, true);
}
}
}
return $new_media;
}
Updates the content of the media when it's deleted and replaced in the bbn-upload BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions