Jump to content

Croppable Image 3


horst

Recommended Posts

6 hours ago, Robin S said:

@horst, what if you create a new module file/class in the root of the CroppableImage3 directory named 'CroppableImage3', and that class does nothing apart from auto-install the other classes?

Not ideal of course but might be an okay workaround seeing as you are stuck with the existing directory name.

Was allready done. It resulted in not correctly installing all needed dependencies (with a wrapper class: three). It only installed two out of three, then complaining about the missing one. System broken! :(

Link to comment
Share on other sites

2 hours ago, horst said:

It resulted in not correctly installing all needed dependencies (with a wrapper class: three). It only installed two out of three, then complaining about the missing one.

Taking the current version of CI3 and adding this 'CroppableImage3.module' file in the module root enabled all the dependent modules to be installed/uninstalled in one go without any major problem for me:

<?php namespace ProcessWire;

class CroppableImage3 extends WireData implements Module {

    public static function getModuleInfo() {
        return array(
            'title'    => 'Croppable Image 3',
            'summary'  => 'One or more image uploads (optional predefined crops)',
            'author'   => 'Horst Nogajski',
            'version'  => '1.1.5',
            'requires' => 'ProcessWire>=3.0.20, PHP>=5.3.8',
            'installs' => 'FieldtypeCroppableImage3, InputfieldCroppableImage3, ProcessCroppableImage3',
            'icon'     => 'crop'
        );
    }

    public function ___uninstall() {
        // Remove related modules on uninstall - not essential
        $this->modules->uninstall('FieldtypeCroppableImage3');
        $this->modules->uninstall('InputfieldCroppableImage3');
        $this->modules->uninstall('ProcessCroppableImage3');
    }

}

Tracy picks up a few minor PHP notices coming from ProcessCroppableImage3 during install/uninstall but should be simple enough to iron those out. Lines 344 & 349 on install, lines 48 & 49 on uninstall - I think these notices occur with the current version too.

If you went this way you could consider moving FieldtypeCroppableImage3.module back into a subfolder just to keep things tidy.

Also, after adding this file the Upgrades module detects CroppableImage3.

  • Like 1
Link to comment
Share on other sites

That's what I made in Version 1.1.0: https://github.com/horst-n/CroppableImage3/commit/6a52e7726170bf3d81981c1d0da9cc247bbaa1b0

-------

Ok, your test was on a first install of the module, and not as an upgrade, yes?

How does it work out for those who have installed a version prior to 1.0.0? Thats the most common and important situation!

You have installed the 3 modules, each in its subfolder or not, but Fieldtype... is the main module, than you use the update module button, (you will need an existing wrapperclass CroppableImage3.module in the github repo for this to work!). <= Thats what I have tried already and it hasn't worked for me. Always left one dependency uninstalled.

But I will try this once more, as 1.1.6, - just to check if my test with 1.1.0 / 1.1.1 wasn't interfered with another issue that made it broken.

Many thanks for your support @Robin S ! :)

Link to comment
Share on other sites

41 minutes ago, horst said:

Ok, your test was on a first install of the module, and not as an upgrade, yes?

Yes, it was just a test of a first install. But just now I forked the module and added the new CroppableImage3.module to the module root (nothing else). With the current CI3 version already installed I installed the modified module via "Add Module From URL": https://github.com/Toutouwai/CroppableImage3/archive/master.zip

This seemed to work without a hitch. Installing via the Upgrades module is perhaps a little different, but I have no way to test that.

  • Like 1
Link to comment
Share on other sites

Due to less time, I will wait until the UIKit Admin is official / stable, before trying to locate and fix incompatibilities. But any pull request is welcomed.

Link to comment
Share on other sites

Just now, horst said:

Due to less time, I will wait until the UIKit Admin is official / stable, before trying to locate and fix incompatibilities. But any pull request is welcomed.

Thank you! :-)

  • Like 1
Link to comment
Share on other sites

3 hours ago, Robin S said:

This seemed to work without a hitch. Installing via the Upgrades module is perhaps a little different, but I have no way to test that.

I will test that again later on, thanks Robin!

Link to comment
Share on other sites

@Robin S, please can you test an update from an installed version prior to 1.1.0?

I have updated the github repo to 1.1.7.

The first "update" has to be done by installing via ClassName in side -> modules -> new: Module Class Name = CroppableImage3

It has worked for me this way. Existing directory was changed / updated with all new files, old unused files were removed.

And now, after that, it is recognized by the updater module! Yeah!

  • Like 3
Link to comment
Share on other sites

5 hours ago, horst said:

The first "update" has to be done by installing via ClassName in side -> modules -> new: Module Class Name = CroppableImage3

Yep, all went smoothly with an update from v1.0.0 beta - nice one :-)

  • Like 2
Link to comment
Share on other sites

Here are the latest "official" notes ;)

 

-------------------------------------------------------------------------

 

Updating from prior versions:

 

Updating from Croppable Image 3 with versions prior to 1.1.7, please do this as a one time step:

In the PW Admin, go to side -> modules -> new, use "install via ClassName" and use CroppableImage3 for the Module Class Name. This will update your existing CroppableImage3 module sub directory, even if it is called a new install. After that, the module will be recogniced by the PW updater module, what makes it a lot easier on further updates. :)

 

-------------------------------------------------------------------------

 

Sticking with a PW legacy 2.8.20+ Version (none namespaced)?

- I have created a CroppableImage2 snapshot, which you can get from the github repo branch: CroppableImage2 


-------------------------------------------------------------------------

  • Like 3
Link to comment
Share on other sites

On 15.10.2016 at 5:00 PM, horst said:

Maybe the setting is not relevant, but saving it one time before open the cropper modal?

I need to test this.

Hey horst.

Really awesome module!! Guess I stumbled upon it once before, but sadly didn't take the time to really check it out.

Anyways... just installed it and saw the same warning as ukyo before "Notice: Undefined property: stdClass::$manualSelectionDisabled". Going to settings screen and hit Submit resolved it. I'm on 3.0.62.

Keep up the good work!

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On 3.9.2016 at 7:59 PM, horst said:

It isn't designed to support this. But I also don't see much disadvantage for this usecase. Lets assume the width you want to support is 1400, 960, 480.

  • Setup the image field with min-width: 1400 and min-height: 788  (= 1400 / 16 * 9)
  • Create a cropsetting image16x9,
  • call it with 100% quality as master-source for the variations

$master = $page->images->first()->getCrop("image16x9", "quality=100");
$large = $master->width(1400);
$medium = $master->width(960);
$small = $master->width(480);

Or directly use the markup srcset module from @tpr and only pass the master to it!

This is what also works for me! But my problem now is, when the user changes the cropping area and saves the image the thumbnail variations are not reset / deleted. Any way this could be done automatically? 

593f99cea0be2_Bildschirmfoto2017-06-13um09_52_12.png.49fc66baf51d7dc7380c3a7665bbaad8.png

Link to comment
Share on other sites

Not really sure about it, but your cropnames uses - chars, what may conflict with the pageimage suffixes. Suffixes are concatenated with the - char. Maybe you can try to change your names from 3-zu-1 to 3zu1?

Link to comment
Share on other sites

No, that does not make a difference. I have to manually delete the variations anyway. 

In the file FieldtypeCroppableImage3ConfAdaptor.php there is a unused function called doTheDishes($deleteVariations=false) but as I see it this is nowhere called.

 

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...
On 6/13/2017 at 1:51 PM, horst said:

Oh, sorry, your are right. This one is old stuff. It is superseeded by: https://github.com/horst-n/CroppableImage3/blob/0946fdce7b1c9859f94adf764df80d73c201bbbc/FieldtypeCroppableImage3/FieldtypeCroppableImage3.module#L364-L365

And this one cleans out every obsolete variation on setting changes.

I think it's a different thing what @dreerr is talking about.

Consider this scenario:

  1. Set a crop setting on an Image field, eg. "work-thumb, 320, 270"
  2. Use it with a srcset solution (either with a module or manually) and that will make you a 320x270 image and some variations - let's assume only one, 160x135:
    image.-work-thumb.jpg
    image.-work-thumb.160x135.jpg

     

  3. Now edit the image again and crop a different part. The results:

    image.-work-thumb.jpg <- changes according to the new crop
    image.-work-thumb.160x135.jpg <- no change!

     

I'm also interested in a solution because CI3 can't be used for srcset purposes atm if I get it right. What I could imagine as a simple fix is that when CI3 saves a new crop it would delete any size variation of it (in this example all images that are named "image.-work-thumb.WIDTHxHEIGHT.jpg"). Then the srcset generators could re-create these size variations again. Perhaps this behavior could be optionally set in the module's settings.

  • Like 5
Link to comment
Share on other sites

  • 2 weeks later...
42 minutes ago, horst said:

@mauricemoss, @ukyo, @dreerr, @tpr

I have uploaded an update to the github repo that fixed the PHP notices and added removal of CropImage children after creating a new CropImage.

I've just upgrade it to the new version. I selected my thumbnail predefined crop and then I cropped a new area of the thumbnail but NONE of the variations removed. What I'm doing wrong?

Link to comment
Share on other sites

Thanks @horst, just checked and I can verify it works as expected!

A few things (nothing biggie):

  • the original image seems to get a new modified date in the filesystem. Is it necessary or a bug?
  • I would love to see a tiny preview of the cropped image (without hover). Would it be possible to append eg. a 0x48px (or so) thumbnail image to the crop size name? Just to have a small indication how it looks like.
  • Tracy shows a PHP notice in the main module's settings page: "PHP Notice: Undefined index: sharpening in .../FieldtypeCroppableImage3ConfAdaptor.php:96"

Anyway I'm happy this issue is fixed, now I can continue uploading images to a site that I put aside. Thanks again!

  • Like 2
Link to comment
Share on other sites

1 hour ago, tpr said:

Thanks @horst, just checked and I can verify it works as expected!

A few things (nothing biggie):

  • the original image seems to get a new modified date in the filesystem. Is it necessary or a bug?
  • I would love to see a tiny preview of the cropped image (without hover). Would it be possible to append eg. a 0x48px (or so) thumbnail image to the crop size name? Just to have a small indication how it looks like.
  • Tracy shows a PHP notice in the main module's settings page: "PHP Notice: Undefined index: sharpening in .../FieldtypeCroppableImage3ConfAdaptor.php:96"

Anyway I'm happy this issue is fixed, now I can continue uploading images to a site that I put aside. Thanks again!

The originals timestamp gets updated because the new settings for the croprectangle (x/ypos & width/height), and sharpening & quality values get stored into dedicated IPTC-fields. (ATM, for jpeg only, what also is the reason for thinking about other solutions)

Tiny previews is a nice idea. If you don't mind I will take your suggestion and bring it into the module.

Will fix that asap.

Many thanks for checking and suggestions! <3

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...