【发布时间】:2019-02-25 14:19:34
【问题描述】:
我有一个关于在 Laravel 中使用intervention.io 调整图像大小的问题(链接:http://image.intervention.io/
我的问题是我不明白如何输入我的代码,有人可以帮我展示这个例子吗?提前谢谢!
我的密码:
account.blade.php:
@extends('layouts.master')
@section('title')
Account
@endsection
@section('content')
<section class="row new-post">
<div class="col-md-6 col-md-offset-3">
<header><h3>Your Account</h3></header>
<form action="{{ route('account.save') }}" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="first_name">First Name</label>
<input type="text" name="first_name" class="form-control" value="{{ $user->first_name }}" id="first_name">
</div>
<div class="form-group">
<label for="image">Image (only .jpg)</label>
<input type="file" name="image" class="form-control" id="image">
</div>
<button type="submit" class="btn btn-primary">Save Account</button>
<input type="hidden" value="{{ Session::token() }}" name="_token">
</form>
</div>
</section>
@if (Storage::disk('local')->has($user->first_name . '-' . $user->id . '.jpg'))
<section class="row new-post">
<div class="col-md-6 col-md-offset-3">
<img src="{{ route('account.image', ['filename' => $user->first_name . '-' . $user->id . '.jpg']) }}" alt="" class="img-responsive">
</div>
</section>
@endif
@endsection
用户.php:
<?php
namespace App;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
class User extends Model implements Authenticatable
{
use \Illuminate\Auth\Authenticatable;
public function posts()
{
return $this->hasMany('App\Post');
}
public function likes()
{
return $this->hasMany('App\Like');
}
}
【问题讨论】:
-
你也想改变宽度或高度吗?您是否安装了干预措施?
-
欢迎您阅读image.intervention.io/use/basics 吗?
-
嗨@gaurav Gupta,是的,我想改变宽度和高度,我还没有安装干预,我怎么能用 Laravel 做到这一点?希望尽快听到。
-
嗨@kerbholz,是的,它不适合我。
标签: php laravel image resize image-resizing