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

Use img_url helper to convert image formats automatically #135

Open
yogeshbeniwal opened this issue Aug 10, 2022 · 4 comments
Open

Use img_url helper to convert image formats automatically #135

yogeshbeniwal opened this issue Aug 10, 2022 · 4 comments

Comments

@yogeshbeniwal
Copy link
Contributor

yogeshbeniwal commented Aug 10, 2022

Ghost 5.7.0, has added the functionality of the img_url helper, it now can convert image formats automatically. Can use this feature to serve smaller size images with webp extension providing same image quality to enhance performance.

@uPagge
Copy link
Contributor

uPagge commented Aug 12, 2022

wow cool feature, but the size is not always smaller.

For my website images, I use the following formula. I distribute them using nginx bypassing the call to Ghost, I also optimized all the images by losslessly compressing them and making a copy of each image in webp.

Thus, if I have webp, then I give it away, if it doesn’t exist, then I give the picture using nginx, and only if it is not in the folder yet, this happens with new pictures, then we send a request to ghost and it creates pictures in its directories and further they will be distributed from there.

It was for general education, suddenly it will be useful to someone, the essence of my message is different. I had jpg pictures weighing 43 kilobytes, after converting to webp they became all 141 kilobytes, I don’t know why, I also thought that webp should be smaller

@yogeshbeniwal
Copy link
Contributor Author

@uPagge Can you share nginx configuration changes and other settings change you are doing to serve images?

@uPagge
Copy link
Contributor

uPagge commented Aug 13, 2022

Sure, here you are

location ~* ^(/blog/content/images/)(.+)\.(png|jpe?g)$ {	
        expires max;
        alias /var/struchkov.dev/ghost/www/images;
        set $webp_image_subdir "/webp/";
        set $basename $2;
        try_files $webp_image_subdir$basename$webp_suffix $uri @ghost;
}

/var/struchkov.dev/ghost/www/images - full path to images
/var/struchkov.dev/ghost/www/images/wepb/ - full path to webp images

@uPagge
Copy link
Contributor

uPagge commented Aug 13, 2022

By the way, I tried this function, but for some reason my images were not converted using Ghost

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

No branches or pull requests

3 participants