spatie/laravel-glide

getURL and Load in v3

Jaspur opened this issue · 5 comments

Hi,

In v2 I did things like:

return GlideImage::load($this->avatar, 
         ['w' => 100, 'h' => 100, 'fit' => 'crop'])->getURL();

But I wanna upgrade to v3, but how to achieve the same? I found out that I had to add the storage_path to the load, but the getURL returns Fatal error: Call to undefined method Spatie\Glide\GlideImage::getURL()

return GlideImage::create(storage_path('app/images/'.$this->avatar), 
     ['w' => 100, 'h' => 100, 'fit' => 'crop'])->getURL();

As far I could see it wasn't possible to use load() anymore, but the docs still shows it:
https://www.dropbox.com/s/3vbc6d1fd8lch2n/Schermafdruk%202016-02-12%2020.25.12.png?dl=0

Hi,

the example on my blog was wrong. I've now corrected it.

To convert an image you can use this code:

return GlideImage::create(storage_path('app/images/'.$this->avatar), 
     ['w' => 100, 'h' => 100, 'fit' => 'crop'])->save();

In v3 the getURL-method does not exist anymore. In fact all functionality regarding url generation and on the fly conversion of images has been removed. If you want to generate url's to stored images/files take a look at our medialibrary.

Ok, then I keep it to v2.

I don’t get it, isn’t the “on the fly conversion” one of the most important functionality of the Glide package? The “simple example” from the Glide documentation suggests so:

<h1><?=$user->name?></h1>

<!-- display profile image cropped to 300x400 -->
<img src="/img/users/<?=$user->id?>.jpg?w=300&h=400&fit=crop">

Maybe I’m misguided but that was most of the appeal of this package to me. Can you explain your decision to remove this functionality?

Currently I'm just using Glide because it provides a beautiful API (passing an array with some keys) to manipulate images. As I only need that functionality in our medialibrary I decided not to code up the on the fly conversion part.

I would accept a fully tested PR that adds that to the package.

Ok thanks for the explanation. I’m not sure that I would be able to do that now, but I may try if I got some free time in the coming weeks.