Comments (4)
Hmm. There are two ways you can do this:
-
The
$model->{attachment}->url()
method should give you the public URL, which you can 'translate' into a local path if your storage solution is consistent. I don't think there is a clean, direct way of getting an 'internal' URL through Paperclip (especially since storage need not be local in any case).
Since the default URL is that of the original file, you should be able to modify that, write it back. This would not affect other variants, of course -- and I'm not sure whether that's what you're asking for.. -
You can make your own variant, and call it 'optimized' f.i. You can write your own variant strategy and make that use the Spatie image optimizer. This is the cleanest approach I can think of and has the added benefit of keeping a non-optimized version of the image.
But maybe I'm misreading your issue, so please let me know what you think, or why your use-case would not be served by the above approaches.
from laravel-paperclip.
Thanks for the insight :)
2 Definitely sounds like the best solution. Would you be open to a PR for an image optimiser strategy as part of FileHandling, or is that outside of its scope?
from laravel-paperclip.
I would definitely be open to it -- welcome it, in fact.
Do keep in mind that the czim/file-handling
package is framework-agnostic. I don't think it's a problem to include framework-specific strategies, as long as the package itself doesn't require the framework because of it.
from laravel-paperclip.
I've just added a PR to file-handling
that is framework agnostic.
from laravel-paperclip.
Related Issues (20)
- Is there a way to timeout remote URL fetches? HOT 1
- Laravel 7 HOT 3
- File goes missing at times after upload HOT 2
- Laravel 7 getAttributes() memory / loop problem HOT 1
- Allowed memory size and large uploads HOT 3
- Feature: attachment-level storage visibility configuration HOT 1
- Saving new Image from url causes Exception HOT 3
- Attachment attributes instantiated even when excluded from select statement HOT 6
- Manually able to trigger rotation on images HOT 2
- Processed variant ignores Orientation EXIF HOT 2
- attaching via url with url encoded filenames is problematic HOT 2
- AutoOrientStep not working in heroku HOT 4
- Strategy for changing interpolation HOT 1
- Re-uploading of image attachment with variants - variants have incorrect extension
- Deprecation Warning When Using PHP 8.1 HOT 2
- Laravel 9 update? HOT 5
- refresh command and s3 storage: new variants not created HOT 2
- paperclip:refresh with vapor and "No space left on device" HOT 3
- Dimentions Issue resize
- Can't delete attachment permanently. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-paperclip.