Mecanik / cloudflare-image-resizing

CloudFlare Image Resizing plugin for WordPress.
MIT License
62 stars 13 forks source link

Possible to use for admin dashboard? #42

Open abhishek-sharma8 opened 6 months ago

abhishek-sharma8 commented 6 months ago

Hi, thank you for this super awesome plugin. It works fine for the frontend, but is it possible to also use it for backend images, like the media library, product images in the edit screen, etc?

I tried both the plugin and the worker but none are rewriting the images in the backend. I'd like to completely get rid of the thumbnails and only keep the original copies on my server.

Mecanik commented 6 months ago

Hi, sorry but I do not understand. Do you want to apply image resizing to the admin area as well?

abhishek-sharma8 commented 6 months ago

Hi, yes. That is correct. I want to apply resizing to the admin area as well. Like thumbnails in the media library page (both list view and grid view) as well as product thumbnails in the Woocommerce products list page, etc.

Mecanik commented 6 months ago

In this case, you have to edit the plugin manually here: https://github.com/Mecanik/cloudflare-image-resizing/blob/93e64f93a13f5abadf5d08c46ae53cce302cdde6/cf-image-resizing/cf-image-resizing.php#L244 (just comment out that line).

abhishek-sharma8 commented 6 months ago

Unfortunately, it does not seem to work. The images are still loading from the server and not Cloudflare

wpsumo commented 6 months ago

@Mecanik I think he mean to rewrite in wp-admin not just allow rewrite when is_admin and is_logged_in @abhishek-sharma8 correct?

abhishek-sharma8 commented 6 months ago

Yes, that is correct @wpsumo To save space on the server when there are thousands of images, I'd like to only keep the original images on the server and no thumbnails. The thumbnail generation should be taken care of by this awesome plugin, which works great for the frontend. But the images are still served from the server on the backend. This is what I am asking. The thumbnails for media files that I see in the media library (150x150 for list view and 300x300 for grid view), can they be served from Cloudflare as well? I did try a few filters but none of them worked.

Mecanik commented 6 months ago

Guys, I still don't understand your use case. Please explain a bit better.

wpsumo commented 6 months ago

I think he want to rewrite everything in wp-admin not sure the reason but maybe to offload the whole media library to cloudflare images? And not storing anything locally? Not sure either but that's what I understand.

Rewrite to offload make sense in one way but disabling resizing is overkill, in wp-admin as there is no point doing it there.

abhishek-sharma8 commented 6 months ago

@Mecanik The thumbnails you see in wp-admin are loaded from the server, not Cloudflare. For example, if you go to the media library, (example.com/wp-admin/upload.php?mode=grid or example.com/wp-admin/upload.php), the thumbnails you see are loaded from the server (150x150 size or 300x300). Same is the case when you add media media through the post and also the product gallery in the product gallery page. I've attached images for these screens, where I want to use Cloudflare images. Hopefully, this explains it better.

@wpsumo, for a smaller site, yes it is an overkill. But I have multiple sites on the same server, with up to 30k images per site. I don't want to offload the images, I only want to keep the original images on the server and use Cloudflare images for generating thumbnails on-demand, including for the wp-admin pages. This will not just save me a lot of storage space but the backups will also be quicker. This is working fine for the front end through this plugin, but backend images, which I am assuming have different filters/hooks, are not working.

I'll try doing it myself if I can, but since I am not a developer, I am less likely to succeed.

https://i.ibb.co/yqrkJmS/media-library.jpg https://i.ibb.co/55dSVfB/media-library-1.jpg https://i.ibb.co/55dSVfB/media-library-1.jpg https://i.ibb.co/55dSVfB/media-library-1.jpg https://i.ibb.co/XkDxSbN/add-media.jpg