Giter Club home page Giter Club logo

grav-plugin-resize-images's Introduction

Grav Resize Images Plugin

This plugin is unmaintained. Feel free to fork and continue development elsewhere.

Resize images at upload time in the Grav admin

Grav provides some nifty built-in features for editing images on the fly through the use of Gregwar/Image. But there's no support yet for automatically generating responsive image alternatives at upload time rather than at request time. This plugin fixes that! It will automatically resize images that are uploaded through the Grav admin to a set of predetermined widths. This means improved performance for Grav, and less manual resizing work for you. Win-win! 🎉

Moreover, this plugin doesn't support just GD, but also Imagick, which means you'll get higher quality results than with the ImageMedium#derivatives method that can be used to generate image alternatives in theme templates.

Images that already have responsive alternatives won't be resized.

Configuration

You can customize the set of widths that your images will be resized to. By default they are 640, 1000, 1500, 2500, 3500 pixels in width. Images will never be scaled up, however, so only the widths that are smaller than the original image's will be used.

For every width, you're also able to set the JPEG compression quality. A good rule of thumb is to lower that number at higher widths - the result will still be good!

This plugin won't convert PNG's to JPEG's, so the quality number only applies to JPEG images.

To generate variations of existing images go into the admin panel and re-save the pages where those images live. Every time a page is saved (whether it's new or old), this plugin will go through all images (again, whether they are new or old) in that page, check if they have responsive variants and generate new ones if necessary.

Installation

Download the ZIP archive from GitHub and extract it to the user/plugins directory in your Grav installation.

CLI

I'm aiming to add support for CLI commands to this plugin as well, to make it easy to generate responsive image alternatives for already uploaded images.

grav-plugin-resize-images's People

Contributors

fredrikekelund avatar tamriel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grav-plugin-resize-images's Issues

Does this only work for destination: 'self@'?

Hi! Thank you for the plugin, @fredrikekelund

Does this only work if the destination on the upload field is set to ‘self@'?
I set mine to "destination: 'page@:/images'" and nothing happened on upload.

Also, re-saving the page did not generate the derivatives of all images already in that page.

question

thank you for this nice plugin.

I am not using the admin panel at all: can I use this plugin anyway?

If so, could you explain in README file how to use it without it?

Thanks in advance

Remove original size image

Hi Fredrik,

This is not an issue - just a question - is it possible to remove or don't add at all the original image once it's done the resizes?

Thanks,

removing some default image sizes won't work

capture-resize
When I delete some unnecessary image sizes after clearing cache they always return.


The main problem with this plugin is that if I have 15 or 20 images in media, it won't handle nicely without noticing that memory limit on shared hosting is exceeding. So plugin should work differently while resizing images or at least let me to remove unnecessary image sizes.

Show resize images under Page Media

Thank you for this plugin.
One thing I would like to see as you continue development is to show the various resized options (plus their filesizes and dimensions) under "Page Media" on the Content tab. Currently only the original images shows, and I have to go look in the folder to see what has happened, which will be different depending on the original dimensions of the image in question.

If the above is not possible, I suppose you could add the resulting image names to the alert that shows after upload.

Where are images located?

Have installed the plugin and configured. Chose GD and Imagick (both installed on server) for conversions. Neither seem to work as cannot see any options to choose images?

I see the image uploaded (both on page and looking in FTP) but see no resized images.

If I do get it working, how do I choose the desired image?

Will the images actually be responsive?

Thanks and sorry for not getting it, very confused.

Susan

Call to a member function resize() on boolean

Hello,

I've started working with Grav and your plugin is very lovely add-on to simplify image issues.

After installing it, I'm trying it on my old blog where I have line like:

![alt text](image.jpg) {.center}

but I get:

Error thrown with message "Call to a member function resize() on boolean"

Stacktrace:
#23 Error in /var/www/html/net.local/user/plugins/resize-images/resize-images.php:72
#22 Grav\Plugin\ResizeImagesPlugin:resizeImage in /var/www/html/net.local/user/plugins/resize-images/resize-images.php:115
#21 Grav\Plugin\ResizeImagesPlugin:onAdminSave in /var/www/html/net.local/vendor/symfony/event-dispatcher/EventDispatcher.php:184
#20 call_user_func in /var/www/html/net.local/vendor/symfony/event-dispatcher/EventDispatcher.php:184
#19 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in /var/www/html/net.local/vendor/symfony/event-dispatcher/EventDispatcher.php:46
#18 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in /var/www/html/net.local/vendor/rockettheme/toolbox/Event/src/EventDispatcher.php:23
#17 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in /var/www/html/net.local/system/src/Grav/Common/Grav.php:272
#16 Grav\Common\Grav:fireEvent in /var/www/html/net.local/user/plugins/admin/classes/controller.php:2003
#15 Grav\Plugin\AdminController:taskSave in /var/www/html/net.local/user/plugins/admin/classes/controller.php:188
#14 call_user_func in /var/www/html/net.local/user/plugins/admin/classes/controller.php:188
#13 Grav\Plugin\AdminController:execute in /var/www/html/net.local/user/plugins/admin/admin.php:324
#12 Grav\Plugin\AdminPlugin:initializeController in /var/www/html/net.local/user/plugins/admin/admin.php:371
#11 Grav\Plugin\AdminPlugin:onPagesInitialized in /var/www/html/net.local/vendor/symfony/event-dispatcher/EventDispatcher.php:184
#10 call_user_func in /var/www/html/net.local/vendor/symfony/event-dispatcher/EventDispatcher.php:184
#9 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in /var/www/html/net.local/vendor/symfony/event-dispatcher/EventDispatcher.php:46
#8 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in /var/www/html/net.local/vendor/rockettheme/toolbox/Event/src/EventDispatcher.php:23
#7 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in /var/www/html/net.local/system/src/Grav/Common/Grav.php:272
#6 Grav\Common\Grav:fireEvent in /var/www/html/net.local/system/src/Grav/Common/Processors/PagesProcessor.php:25
#5 Grav\Common\Processors\PagesProcessor:process in /var/www/html/net.local/system/src/Grav/Common/Grav.php:121
#4 Grav\Common\Grav:Grav\Common\{closure} in /var/www/html/net.local/system/src/Grav/Common/Grav.php:358
#3 Grav\Common\Grav:Grav\Common\{closure} in /var/www/html/net.local/system/src/Grav/Common/Grav.php:334
#2 call_user_func_array in /var/www/html/net.local/system/src/Grav/Common/Grav.php:334
#1 Grav\Common\Grav:__call in /var/www/html/net.local/system/src/Grav/Common/Grav.php:122
#0 Grav\Common\Grav:process in /var/www/html/net.local/index.php:45

Any hint?

Image Cache

Hi Fredrike.

Great plugin! I have one major concern:

When cache all images is enabled in the Grav Admin for the site the plugin generates the derivates inside the image cache and not inside of the page folder. You should offer to temporarily set the system.images.cache_all to false if it's true and after admin_save is done you can reset to true.

This has the benefit to load smaller images for the previews in filepicker, pagemedia fields in admin.

Regards.
uh

Add a CLI that can generate image alternatives for existing images

I'd like to add a CLI that lets people generate new image sizes for existing images. It would be nice to be able to target all pages, all page children or a single page. This also enables people that aren't using the admin plugin to generate image alternatives.

resize-images.yaml ignored with environment folder

This plugin seems not to respect the Grav principle of config inheritance.

It should get its configuration from:

user/config/plugins/resize-images.yaml

then override it with:

user/localhost/config/plugins/resize-images.yaml

Instead, this plugin - when on localhost - goes directly looking for user/localhost/config/plugins/resize-images.yaml. The master configuration gets ignored and it leads to the plugin defaults being used in that case. In other cases it results in many other issues.

#11 is probably related

PNG thumbnails don't retain transparency

Hello,
First off, LOVE YOUR PLUGIN. This is awesome. So minimal, yet it's all I need. That being said, I noticed the PNGs I upload that have a transparent background do not retain the transparent background on thumbnails produced.
I think something simple needs to be set to detect the transparency and ensure thumbnails inherit it as well. Possibly something like:

$imagick->setBackgroundColor(new ImagickPixel('transparent'));

I'm not quite at your level to write this stuff, but I'm more than happy to keep using and testing your plugin to help it reach mythical CMS Image Manager Perfection status :)

Improve adapter picking logic

If either Imagick or GD is available, the plugin should always pick one of them, regardless of the image adapter setting.

If it falls back to an option that isn't installed, it should also show a warning in the admin interface about this.

How to get the biggest image?

Using the plugin, all images uploaded on a page have multiple versions name.jpg, [email protected], [email protected]....

Is there a simple way to display the biggest one with TWIG? The problem being that the number of versions depends on the original image size.

I tried this without success:

{{ image.sizes('100vw').url }}

Trying the get an absolute size also does not work:

{{ image.derivatives(2000).url }}

How i delete generated images ?

When i don't need to use in specific page or if i desactivate plugins. Grav keep using your generated images.
How i clean cache ?

Call to a member function resize() on a non-object

When I try to save page with uploaded image I get following error:

Whoops\Exception\ErrorException thrown with message "Call to a member function resize() on a non-object"

Stacktrace:
#0 Whoops\Exception\ErrorException in /Users/kaladivo/Downloads/grav-admin/user/plugins/resize-images/resize-images.php:72

How to get all images in an array?

Thanks a lot for this plugin. I am pretty much new to grav.

I tried to use {{ image.derivatives(theme.image_sizes_px).sizes(sizes_attribute).html() }} which works but it takes a lot of time to generate all the images when the cache is cleared. Then I tried your plugin, which generate all responsive images on page save inside page folder and everything works fine. Now I am using {{ image.sizes(sizes_attribute).html() }} which gives me the right img tag with srcset. But if I want to get all the newly created image([email protected], [email protected]) for 'test.jpg' what should I do? Should it be inside page.media['test.jpg']?

I have no clue about how to get all images in an array.

Error: Call to a member function resize() on boolean

Hi,

I have tried your plugin and when I want to save a page in the admin panel I get this error message:

Error 
…/user/plugins/resize-images/resize-images.php:72

This error happens when I use an image file without @[density-ratio]x in the filename.

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.