laravel livewire 干预图像
laravel livewire intervention images
我正在尝试将干预图像与 Livewire 结合使用来减小尺寸,但我没有成功。他们可以指导我或告诉我 Livewire 是否不允许。
我正在尝试通过此方法:
foreach ($this->imagenes as $pathGaleria) {
$imgUrl = $pathGaleria->store('imagenesPropiedades');
$img = imgPropiedades::create([
'url' => $imgUrl,
'property_id' => $this->propiedadId
]);
另一种方式:
foreach ($this->imagenes as $pathGaleria) {
$imgUrl = $pathGaleria->store('imagenesPropiedades');
Image::make($pathGaleria)->resize(1200, null, function ($constraint) {
$constraint->aspectRatio();
})
->save($imgUrl);
$img = imgPropiedades::create([
'url' => $imgUrl,
'property_id' => $this->propiedadId
]);
}
但页面仍然空白。谢谢。
我今天找到这个,可能对你有用
https://gist.github.com/daugaard47/659984245d31b895d00ee5dcbdee44ec
+
$images = Collection::wrap($request->file('file'));
$images->each(function ($image) use ($id) {
$basename = Str::random();
$original = $basename . '.' . $image->getClientOriginalExtension();
$thumbnail = $basename . '_thumb.' . $image->getClientOriginalExtension();
ImageManager::make($image)
->fit(250, 250)
->save(public_path('/images/' . $thumbnail));
$image->move(public_path('/images/'), $original);
Model::create([
]);
});
我正在尝试将干预图像与 Livewire 结合使用来减小尺寸,但我没有成功。他们可以指导我或告诉我 Livewire 是否不允许。
我正在尝试通过此方法:
foreach ($this->imagenes as $pathGaleria) {
$imgUrl = $pathGaleria->store('imagenesPropiedades');
$img = imgPropiedades::create([
'url' => $imgUrl,
'property_id' => $this->propiedadId
]);
另一种方式:
foreach ($this->imagenes as $pathGaleria) {
$imgUrl = $pathGaleria->store('imagenesPropiedades');
Image::make($pathGaleria)->resize(1200, null, function ($constraint) {
$constraint->aspectRatio();
})
->save($imgUrl);
$img = imgPropiedades::create([
'url' => $imgUrl,
'property_id' => $this->propiedadId
]);
}
但页面仍然空白。谢谢。
我今天找到这个,可能对你有用
https://gist.github.com/daugaard47/659984245d31b895d00ee5dcbdee44ec
+
$images = Collection::wrap($request->file('file'));
$images->each(function ($image) use ($id) {
$basename = Str::random();
$original = $basename . '.' . $image->getClientOriginalExtension();
$thumbnail = $basename . '_thumb.' . $image->getClientOriginalExtension();
ImageManager::make($image)
->fit(250, 250)
->save(public_path('/images/' . $thumbnail));
$image->move(public_path('/images/'), $original);
Model::create([
]);
});