✨ Ajoute la gallerie
On utilise une libraire pour créer les miniatures Fix #4
This commit is contained in:
16
app/User.php
16
app/User.php
@@ -42,20 +42,4 @@ class User extends Authenticatable
|
||||
$arrayHash = str_split(strtolower(md5($this->id)));
|
||||
return sprintf('%s/%s', $arrayHash[0], $arrayHash[1]);
|
||||
}
|
||||
|
||||
public function getImageData(Post $post)
|
||||
{
|
||||
if (empty($post->image)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$path = sprintf('%s/%s/%s', storage_path('app'), $this->getFolder(), $post->image);
|
||||
|
||||
if (!is_readable($path)) {
|
||||
return '';
|
||||
}
|
||||
$type = pathinfo($path, PATHINFO_EXTENSION);
|
||||
$data = file_get_contents($path);
|
||||
return sprintf('data:image/%s;base64,%s', $type, base64_encode($data));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user