GithubHelp home page GithubHelp logo

kirby-autoresize's Introduction

👨‍💻 My name is Thomas Günther and I'm a web designer and developer.

👨‍🍳 I come from a family of bakers, hence I'm a Medienbäcker.

💆‍♂️ I almost exclusively use Kirby.

🌲 I live in the black forest.

kirby-autoresize's People

Contributors

medienbaecker avatar preya avatar sinoboeckmann 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  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  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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kirby-autoresize's Issues

Ability to prevent resizing on specific pages/templates

Although the image resizing features is very useful on most pages, there might be occasions you want to allow users to upload in higher resolution, for specific use-cases. What about having an ignore_page (Array) or ignore_template (Array) setting in the config file?

Suggestion: Quality setting

Hey @medienbaecker, first of all: I love this plugin, big up!
Is it possible to add the option to change the quality of the image? (Like the Kirby Resize option)
All the best, K

More Options (scale by maximum height and scale by longest side)

Hi,

thanks for Your plugin!
I have extended it a little bit, since I needed an option to also scale down images in portrait mode.
It's also possible to set up a "longest side", and the script will then take care of both orientations (maxWidth & maxHeight will be ignored, if given).
I'm sure, this can be optimized, but maybe someone finds it useful anyway.

Cheers,
Cris

// config.php
'medienbaecker.autoresize.sizes' => [
        'maxWidth'     => 1600, // landscapes
        'maxHeight'    => 1200, // portraits
        //'longestSide'  => 1200, // portrait and landscape
    ],
// index.php
Kirby::plugin('medienbaecker/autoresize', [
   'options' => [
        'sizes' => [
            'maxWidth'    => 1600,
            'maxHeight'   => 1600,
            'longestSide' => null,
          ]
    ],
    
    'hooks' => [
        'file.create:after' => function ($file) {
          
            $option = option('medienbaecker.autoresize.sizes');
            $mW = $option['maxWidth'];
            $mH = $option['maxHeight'];
            $ls = $option['longestSide'];
            
            $oldW = $file->width();
            $oldH = $file->height();
            
            if(!empty($ls)){
              $maxW = $ls;
              $maxH = $ls;
            } else {
              $maxW = $mW;
              $maxH = $mH;
            };
          
          
            if($file->isResizable()) {
              if($oldW > $maxW || $oldH > $maxH){
                    try {
                        kirby()->thumb($file->root(), $file->root(), [
                            'width'  => $maxW,
                            'height' => $maxH,
                        ]);
                    } catch (Exception $e) {
                        throw new Exception($e->getMessage());
                    }
                 }
            }
        },
        'file.replace:after' => function ($newFile, $oldFile) {
            kirby()->trigger('file.create:after', $newFile);
        }
    ]
]);

Error when replacig an image

The autocrop works fine for new images, but when I try to replace an existing image I get

Argument 2 passed to Kirby\Cms\App::trigger() must be of the type array, object given,
called in /rootpath/plugins/autoresize/index.php on line

Any ideas how to fix?

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.