Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rearchitect everything #4

Open
joshmanders opened this issue Oct 27, 2024 · 0 comments
Open

Rearchitect everything #4

joshmanders opened this issue Oct 27, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@joshmanders
Copy link
Member

Right now when you call the og_image() helper function it returns a Image class that extends Illuminate\Http\Response and sets it up so that way Laravel will get an image file response to return back to the browser.

This class also has a __call() method on it to proxy any additional methods off to the Base64EncodedImage class that extends the Illuminate\Http\UploadedFile class and restores the base64 encoded image from Chrome as a temporary file so that you can use all the file manipulation stuff you're used to from uploading files in Laravel.

Both those are great currently.. But while working on my own projects I realized that originally I wanted the ability to have more control over my OG image generation, which is why those two abilities exist. But now I'm becoming to really come around to just using the /og-image url for everything...

So I thought, why not just do

<img src="{{ og_image('example', ['title' => 'Hello World']) }} />

But that don't work in the current state because it generates the screenshot and that slows the request down immensely and no bueno.

So we'll re-architect it in a way that if you return from a route handler/controller Laravel gets a responsable interface implemented so that it can handle that use case correctly, which would also execute Chrome under the hood to generate the image.

It would also implement a uploaded file interface so you get all those goodies still too.

But if executed in the context above, like in a blade template, where it'll get called to be transformed into a string, then in that case we just the /og-image route with the query string passed through, so you'd end up getting the string

https://example.com/og-image?template=example&title=hello%20world

Thus making all of these use cases work!

@joshmanders joshmanders added the enhancement New feature or request label Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant