method update documentation in bbn\Appui\Medias
updates the title or the name or the title of the given media at the level of the file and database
function(string $id_media, string $name, string $title)
{
$new = [];
//the old media
$old = $this->getMedia($id_media, true);
if ($old && (($old['name'] !== $name) || ($old['title'] !== $title))) {
$content = $old['content'];
if (\bbn\Str::isJson($content)) {
$content = \json_decode($content, true);
}
if ($this->fs->exists($old['file'])) {
if ($old['name'] !== $name) {
//if the media is an image has to update also the thumbs names
if ($this->isImage($old['file'])) {
$thumbs_names = [
[
'old' => $this->getThumbsName($old['name'], [60,60]),
'new' => $this->getThumbsName($name, [60,60])
],[
'old' => $this->getThumbsName($old['name'], [100,100]),
'new' => $this->getThumbsName($name, [100,100])
],[
'old' => $this->getThumbsName($old['name'], [125,125]),
'new' => $this->getThumbsName($name, [125,125])
]
];
foreach ($thumbs_names as $t){
$this->fs->rename($path.$id_media.'/'.$t['old'], $t['new'], true);
}
}
$this->fs->rename($path.$id_media.'/'.$old['name'], $name, true);
}
if ($this->updateDb($id_media, $name, $title)) {
$new = $this->getMedia($id_media, true);
}
}
return $new;
}
return $new;
}
updates the title or the name or the title of the given media at the level of the file and database 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