Git Product home page Git Product logo

Comments (4)

czim avatar czim commented on June 3, 2024

Hmm. There are two ways you can do this:

  1. 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..

  2. 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.

kyranb avatar kyranb commented on June 3, 2024

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.

czim avatar czim commented on June 3, 2024

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.

kyranb avatar kyranb commented on June 3, 2024

I've just added a PR to file-handling that is framework agnostic.

czim/file-handling#6

from laravel-paperclip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.