CTOlet / yii2-attachments

Yii2 extension for uploading and attaching the files to the models
66 stars 57 forks source link

How to get the url to the already uploaded image #73

Closed YuriyPrudnikov closed 1 year ago

YuriyPrudnikov commented 5 years ago

Hello! How to get image url? The getUrl method is not appropriate, as it does not return the absolute path to the image)

dmkdesign commented 1 year ago

I believe this is not possible in the way you are thinking. "Attachments" protects the url route to the storage location using a fileController. The storage location is also hashed to improve file retrieval speed. So really the "file" is retrieved using $response->sendFile(). I have added the ability to get the file "inline" instead of by downloading by using $file->getUrl($inline=true). As well, if you use getUrl in an image tag it works as intended.