调整图像的宽度和高度 (Model-Blade) Laravel

Adjust a width and height to an image (Model-Blade) Laravel

我正在尝试调整具有特定宽度和高度的图像,但它与 blade 相呼应,我不知道如何调整。

这是代码:

在blade中:

<li style="text-align:center"><strong>Fotos:</strong>
    @forelse($publication->photos()->get() as $key => $photo)
    <div>
        {{ $photo->image }}
    </div>
    @empty
    EL usuario no ha agregado fotos
    @endforelse
</li>

模型中的方法 photos():

public function photos()
{
    return $this->hasMany('BookPublicationPhoto', 'published_book_id');
}

这是结果(照片超出页面宽度)

http://imgur.com/5b5ui5J

知道我该如何继续吗?

解决方案

我有其他模型具有 image 方法,所以我只是添加了宽度和高度:

public function getImageAttribute()
{
    return HTML::image('img/publication/'.$this->published_book_id.'/'.$this->image_file_name, '-', ['class' => 'thumb', 'width' => 150, 'height' => 200]);
}

您可以安装 LaravelCollective 包,并使用下面的代码设置高度和宽度。

{{ HTML::image('image_url','image alt title',['width'=>'100','height'=>'200']) }}