Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Unable to load mimetype within cache function #87

Open
scottybo opened this issue Jan 5, 2018 · 0 comments
Open

Unable to load mimetype within cache function #87

scottybo opened this issue Jan 5, 2018 · 0 comments

Comments

@scottybo
Copy link

scottybo commented Jan 5, 2018

If I try to get the mime of the image within the cache function (code below) I get the following error:

"call_user_func_array() expects parameter 1 to be a valid callback, class 'Intervention\Image\ImageManager' does not have a method 'mime'"

            // pass calls to image cache
            $img = Image::cache(function($image) use ($imageUrl, $width, $height) {
                $mime = $image->mime();
                if (!empty($width) && !empty($height)) {
                    $image->make($imageUrl)->fit($width, $height)->encode();
                } else {
                    $image->make($imageUrl)->encode();
                }
            },525600);

It works fine if I use Image:: within the function, but then I'm loading the image again which defeats the purpose of the cache.

I want to be able to detect the mimetype and change the encoding if it's (For example) a bmp or tiff, but leave all other images in the same type (eg png)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant