Jump to content
horst

Croppable Image 3

Recommended Posts

Hello Horst,

thanks for your prompt answere. The page under Admin > Pages was missing. I have reinstalled the module and now everything works fine. Thanks!!!!

Share this post


Link to post
Share on other sites

@horst It's great to see croppableImage back and available again for 3.X 

Is this version here to stay or is there a risk that upcoming changes to get to 3.1 will break functionality?

Share this post


Link to post
Share on other sites

This is the version to stay. It is close to get stable 1.0.0 ! :)

The quirks with the first tries in PW3 was mainly because of misunderstandings between Ryan and me when first time talking about the changes in core image field. And also because my insuficient knowledge of PW ;)

But know we have a solution that (only) extends the core image field with additional functionality. Possible changes, enhancements on the core imagefield will automatically inherited know, like it was with the versions before the core image change.

  • Like 4

Share this post


Link to post
Share on other sites
15 hours ago, horst said:

and its now approved and available in the modules directory: http://modules.processwire.com/modules/croppable-image3/ :)

Come on, @horst! You could be a modest person, but publishing modules under different names is too much. I am used to rely on authority a bit while choosing a module to download. Your name and the vast amount of good stuff made under it has always assured me I can trust that another one new. Probable same for others. Or is some technical issue?

  • Like 1

Share this post


Link to post
Share on other sites

Simply overseen this. I think, when adding a module to the directory, most inputfields get prepopulated with the github-data, where my name is "horst-n", because "horst" wasn't available.

But I could change the module authors name to "horst". :) Thanks for pointing me to it!

Share this post


Link to post
Share on other sites

I also just removed the horst-n author name from the dropdown list of authors.

  • Like 2

Share this post


Link to post
Share on other sites

Feature request: Would it be possible to define an aspect ration (16:9, 4:3, …) instead of using px values? I have a case where I want to output different resolutions for retina/desktop/mobile/… and want to avoid a loss of resolution due to cropping (putting high px doesn't make sense either because not always the client has high resolution images at hand…)

  • Like 2

Share this post


Link to post
Share on other sites

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!

Edited by horst
added link to markup srcset
  • Like 2

Share this post


Link to post
Share on other sites

hi horst,

just wanted to mention that  if you change an existing imagefield to croppableimage3 it will NOT show the crop settings on the input tab. after saving the field the textarea showed up correctly. maybe that could happen automatically?

thanks for one of those essential modules finally on pw3!

Share this post


Link to post
Share on other sites

I believe, saving the field before any changes can take effect is mandatory.

Share this post


Link to post
Share on other sites

sorry horst, i was unclear! of course i changed the type to croppableimage3 and SAVED it. then i looked around and around and clicked tab after tab... it was set to croppableimage3 but the textarea for the settings was not there! i cleared the cache, still not there. then i saved the field AGAIN and it finally appeared ;)

not a big deal but still worth to improve i think (if i'm not the only one experiencing this for whatever reason...)

Share this post


Link to post
Share on other sites

Enclosed you find a json file with my attempt of a GERMAN translation. Feedback is welcome (please as PM so we do not loose focus on the main topic of this thread.)

If everything's fine, I will pass it to the German language team for inclusion with the forth-coming PW V3 strings.

site--modules--croppableimage3--lang--croppableimage3textcollection-php.json

  • Like 2

Share this post


Link to post
Share on other sites

Anyone successfully using CroppableImage3 in a repeater field?

I just converted a CropImage field (used in a repeater) over to CroppableImage3 and get an error every time I try to edit any page with the repeater on now (the front end is working fine.) It's possible this is a problem with the repeater code though.

Share this post


Link to post
Share on other sites

This is resolved now. It was a problem with the underlying repeater, not the CroppableImage3 field in it. I had earlier used the API to migrate a new field into the template used by the repeater but forgot to reflect the change in the field data (specifically, the repeaterFields settings on the field.) Now I have the repeater and its template in sync, all works well. 

  • Like 2

Share this post


Link to post
Share on other sites

As promised, here's the script with delete powers. Only tested on a small subset of an installation I'm switching over to CroppableImage3 so do your own testing please!

Spoiler

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>CropImage &rArr; CroppableImage3 File Conversion</title>
    <style>
.missing     {text-decoration:line-through;}
.error       {background-color:#FDD;}
.ok          {background-color:#DFD;}
.take-action {background-color:#DDF;}
    </style>
  <head>
  <body>
    <h1>CropImage &rArr; CroppableImage3 Image File Migration</h1>
    <h2>Candidate Fields</h2>
<?php
// for PW3+
// (UPDATES by @jacmaes   bugfix for $new filename from below post!)
// (UPDATES by @netcarver debugIteration bugfix, PW3 compatibility, formatting tweaks, source file deletion switch)

$debugIteration = true;     // true to iterate only over the first page with a desired field, false to iterate over all pages
$doFilecopy     = false;    // true to really copy variation files, false for debug purposes

/** ========================= BE VERY SURE YOU WANT TO PROCEED IF SETTING THE FOLLOWING TO TRUE ========================
 * Set the following boolean to true if you want the original image variation files deleted.
 *
 * In order to prevent total loss of the images, deletion is only attempted if...
 * $doOldfileDeletion is true **AND** $doFileCopy is false **AND** the original file exists **AND** the replacement file exists
 * ========================== BE VERY SURE YOU WANT TO PROCEED IF SETTING THE FOLLOWING TO TRUE ========================*/
$doOldfileDeletion = false; // true to delete old file variations.


$oldFieldtype = 'CropImage';
$newFieldtype = 'CroppableImage3';
$timelimit = 120;  // per single page

// bootstrap PW
include(dirname(__FILE__) . '/index.php');


// collect fields and cropsetting names
$collection = array();
echo "<ul>";
foreach($fields as $f) {
    if($f->type != 'Fieldtype' . $oldFieldtype) continue;
    $collection[$f->name] = array();
    echo "<li>{$f->type} : {$f->name}</li>";
    $thumbSettings = preg_match_all('#(.*?),.*?\n#msi' , trim($f->thumbSetting) . "\n", $matches, PREG_PATTERN_ORDER);
    if(!$thumbSettings) continue;
    $collection[$f->name] = $matches[1];
    echo "<ul>";
    foreach($collection[$f->name] as $suffix) {
        echo "<li>{$suffix}</li>";
    }
    echo "</ul>";
}
echo "</ul>";
echo "<hr />";
// We also have to look at CroppableImage3 fields because, after you change your fields over, the above search won't
// find the assets that now need deleting...
echo "<ul>";
foreach($fields as $f) {
    if($f->type != 'Fieldtype' . $newFieldtype) continue;
    $collection[$f->name] = array();
    echo "<li>{$f->type} : {$f->name}</li>";
    $thumbSettings = preg_match_all('#(.*?),.*?\n#msi' , trim($f->cropSetting) . "\n", $matches, PREG_PATTERN_ORDER);
    if(!$thumbSettings) continue;
    $collection[$f->name] = $matches[1];
    echo "<ul>";
    foreach($collection[$f->name] as $suffix) {
        echo "<li>{$suffix}</li>";
    }
    echo "</ul>";
}
echo "</ul>";
echo "<hr />";

$pages_visited      = 0;
$images_visited     = 0;
$variations_visited = 0;
$variations_copied  = 0;
$variations_deleted = 0;

// now iterate over all pages and rename or copy the crop variations
echo "<h2>Asset Scan</h2>";
echo "<ul>";
foreach($pages->find("include=all") as $p) {
    set_time_limit($timelimit);  // reset the timelimit for this page
    foreach($collection as $fName => $suffixes) {
        if(!$p->$fName instanceof \ProcessWire\Pageimages) {
            continue;
        }
        $images = $p->$fName;
        if(0 == $images->count()) {
            continue;
        }
        echo "<li>Page \"<strong>{$p->title}</strong>\" <em>directory \"site/assets/files/{$p->id}/\"</em><ol>";
        foreach($images as $image) {
            echo "Image \"<strong>{$image->name}</strong>\"<ul>";
            $images_visited++;
            foreach($suffixes as $suffix) {
                $variations_visited++;
                $errors  = array();
                $dispold = "{$suffix}_" . $image->name;
              	$dispnew = str_replace(".", ".-{$suffix}.", $image->name);

                $dir = dirname($image->filename).'/';
                $old = $dir . $dispold;
                $new = $dir . $dispnew;

                $old_present = file_exists($old);
                $new_present = file_exists($new);

                /* if (!$old_present) $dispold = "<span class='missing error'>$dispold</strike> (missing)"; */
                /* if ( $new_present) $dispnew = "<span class='ok'>$dispnew</span> (present)"; */

                $old_classes = array();
                $new_classes = array();
                $msg         = '';
                if (!$old_present) $old_classes[] = 'missing';
                if (!$new_present) $new_classes[] = 'missing';

                if (!$old_present && !$new_present) {
                    // Both missing => Cannot migrate this variation, it needs to be regenerated from the original.
                    $old_classes[] = 'error';
                    $new_classes[] = 'error';
                    $msg           = '<span class="take-action">Recreate from source image</span>';
                } else if (!$old_present &&  $new_present) {
                    // Old not there, new is => All done! Migration complete
                    $msg           = '<span class="ok">Migrated</span>';
                } else if ( $old_present && !$new_present) {
                    // Old there, new not there => Ready to copy!
                    $new_classes[] = 'take-action';
                    if (!$doFilecopy) $msg = 'Ready to copy';
                } else {
                    // Both present, ready to delete old copy!
                    $old_classes[] = 'error';
                    if (!$doOldfileDeletion) $msg = 'Ready to delete original';
                }

                $old_classes = implode(' ', $old_classes);
                $new_classes = implode(' ', $new_classes);
                echo "<li><em>Variation: $suffix</em> &mdash; <span class='$old_classes'>$dispold</span> &rArr; <span class='$new_classes'>$dispnew</span> <strong>$msg</strong>";
                if($doFilecopy && $old_present && !$new_present) {
                    $res = @copy($old, $new);
                    if ($res) {
                        $variations_copied++;
                        $res = "<span class='ok'>Success</span>";
                    } else {
                        $res = "<span class='error'>FAILED</span>";
                    }
                    echo " <strong>Filecopy: $res</strong>";
                }

                if (!$doFilecopy && $doOldfileDeletion && $old_present && $new_present) {
                    $res = @unlink($old);
                    if ($res) {
                        $variations_deleted++;
                        $res = "<span class='ok'>Success</span>";
                    } else {
                        $res = "<span class='error'>FAILED</span>";
                    }
                    echo " <strong>Delete of original: $res</strong>";
                }

                echo "</li>";
            }
            echo "</ul>";
        }
        echo "</ol></li>";
        if($debugIteration) break;
    }
    $pages->uncache($p); // just in case we need the memory
    $pages_visited++;
    if($debugIteration) break;
}
echo "</ul><p>Visited $pages_visited pages.</p>";
echo "<p>Visited $images_visited images.</p>";
echo "<p>Visited $variations_visited variations.</p>";
echo "<p>Copied  $variations_copied variations.</p>";
echo "<p>Deleted $variations_deleted variations.</p>";
?>
  </body>
</html>

 

cropImage3-02.png

  • Like 5

Share this post


Link to post
Share on other sites

I finally took the plunge and installed pw 3.x... and of course CroppableImage3.... 
Honestly, CroppableImage was one of the reasons pw 3.x was a no-go for a long time.... 

I was just wondering, if the 'Crop' [from the original Image field] could be hidden somehow, since I don't want the user creating 5 different variations without purpose anyway... [or should this be asked in a different forum area?]

Excellent module nevertheless and always in my top3!

Share this post


Link to post
Share on other sites
18 minutes ago, videokid said:

Honestly, CroppableImage was one of the reasons pw 3.x was a no-go for a long time.... 

same here. but i went the risky way and it was released just in time :) i still think that this should be a core feature...

you could hide the button easily with some JS or CSS, for example using admin custom files or a little hook. do this once and you will be able to do many other little tweaks in the admin without asking for support ;)

  • Like 2

Share this post


Link to post
Share on other sites
12 minutes ago, bernhard said:

you could hide the button easily with some JS or CSS, for example using admin custom files or a little hook.

Your absolutely right! I'm already using Admin Custom Files.... I guess sometimes the obvious isn't obvious enough... :mellow:

Share this post


Link to post
Share on other sites

First of all: Great module! I just ran into one issue though, perhaps I`m doing something wrong here, but when i`m accept the image the cropped image is created and available in the assets, but in the not showing (or replacing) the image in the backend.

gif.gif

Share this post


Link to post
Share on other sites

You mean, the popup thumbnail, that appears when you hover the crop-button, isn't updated automatically when you close the editor popup window?

Share this post


Link to post
Share on other sites

Hi Horst. I mean the image itself. What I would expect is that the cropped image would replace the uploaded one so the one under homepage afbeelding in the gif. Thanks!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Mike Rockett
      Jumplinks for ProcessWire
      Release: 1.5.56
      Composer: rockett/jumplinks
      Jumplinks is an enhanced version of the original ProcessRedirects by Antti Peisa.
      The Process module manages your permanent and temporary redirects (we'll call these "jumplinks" from now on, unless in reference to redirects from another module), useful for when you're migrating over to ProcessWire from another system/platform. Each jumplink supports wildcards, shortening the time needed to create them.
      Unlike similar modules for other platforms, wildcards in Jumplinks are much easier to work with, as Regular Expressions are not fully exposed. Instead, parameters wrapped in curly braces are used - these are described in the documentation.
      Under Development: 2.0, to be powered by FastRoute
      As of version 1.5.0, Jumplinks requires at least ProcessWire 2.6.1 to run.
      View on GitLab
      Download via the Modules Directory
      Read the docs
      Features
      The most prominent features include:
      Basic jumplinks (from one fixed route to another) Parameter-based wildcards with "Smart" equivalents Mapping Collections (for converting ID-based routes to their named-equivalents without the need to create multiple jumplinks) Destination Selectors (for finding and redirecting to pages containing legacy location information) Timed Activation (activate and/or deactivate jumplinks at specific times) 404-Monitor (for creating jumplinks based on 404 hits) Additionally, the following features may come in handy:
      Stale jumplink management Legacy domain support for slow migrations An importer (from CSV or ProcessRedirects) Feedback & Feature Requests
      I’d love to know what you think of this module. Please provide some feedback on the module as a whole, or even regarding smaller things that make it whole. Also, please feel free to submit feature requests and their use-cases.
      Note: Features requested so far have been added to the to-do list, and will be added to 2.0, and not the current dev/master branches.
      Open Source

      Jumplinks is an open-source project, and is free to use. In fact, Jumplinks will always be open-source, and will always remain free to use. Forever. If you would like to support the development of Jumplinks, please consider making a small donation via PayPal.
      Enjoy! :)
    • By BitPoet
      As threatened in Ryan's announcement for 3.0.139, I built a little module for sliding toggles as a replacement for checkboxes. Styling of the input is CSS3 only (with all the usual caveats about older browsers), no JS necessary, and may still be a bit "rough around the edges", so to speak, since I didn't have much time for testing on different devices or brushing things up enough so I'd feel comfortable pushing it to the module directory. But here's the link to the GitHub repo for now:
      InputfieldSlideToggle
      Fieldtype and Inputfield that implements smartphone-style toggles as replacement for checkbox inputs. The visualization is CSS-only, no additional JS necessary.
      Status
      Still very alpha, use with caution!
      Features / Field Settings
      Size
      You can render the toggles in four different sizes: small, medium, large and extra large.
      Off Color
      Currently, "unchecked" toggles can be displayed either in grey (default) or red.
      On Color
      "Checked" toggles can be rendered in one of these colors: blue (default), black, green, grey, orange or red.
      Screenshots

      Some examples with checkbox label


      View all Size and Color Combinations
      Small toggles Medium toggles Big toggles Extra big toggles  









    • By Orkun
      Hi Guys
      I needed to add extended functionalities for the InputfieldDatetime Module (module is from processwire version 2.7.3) because of a Request of Customer.
      So I duplicated the module and placed it under /site/modules/.
      I have added 3 new Settings to the InputfieldDatetime Module.
      1. Day Restriction - Restrict different days based on weekdays selection (e.g. saturday, sunday) - WORKING

       
      2. Time Slots - Define Time slots based on custom Integer Value (max is 60 for 1 hour) - WORKING

       
      3. Time Range Rules per Weekday - Define a minTime and MaxTime per Weekday (e.g. Opening Hours of a Restaurant) - NOT WORKING PROPERLY

       
      The Problem
      Time Slots and Day Restriction working fine so far. But the Time Range Rules per Weekday doesn't work right.
      What should happen is, that when you click on a date, it should update the minTime and maxTime of the Time Select.
      But the change on the select only happens if you select a date 2 times or when you select a date 1 time and then close the datepicker and reopen it again.
      The time select doesn't get change when you select a date 1 time and don't close the picker.
      Here is the whole extended InputfieldDatetime Module.
      The Files that I have changed:
      InputfieldDatetime.module InputfieldDatetime.js jquery-ui-timepicker-addon.js (https://trentrichardson.com/examples/timepicker/) - updated it to the newest version, because minTime and maxTime Option was only available in the new version  
      Thats the Part of the JS that is not working correctly:
      if(datetimerules && datetimerules.length){ options.onSelect = function(date, inst) { var day = $(this).datetimepicker("getDate").getDay(); day = day.toString(); var mintime = $(this).attr('data-weekday'+day+'-mintime'); var maxtime = $(this).attr('data-weekday'+day+'-maxtime'); console.log("weekday: "+day); console.log("minTime: "+mintime); console.log("maxTime: "+maxtime); var optionsAll = $(this).datetimepicker( "option", "all" ); optionsAll.minTime = mintime; optionsAll.maxTime = maxtime; $(this).datetimepicker('destroy'); $(this).datetimepicker(optionsAll); $(this).datetimepicker('refresh'); //$.datepicker._selectDate($(this).attr("id"),date); //$.datepicker._base_getDateDatepicker(); // var inst = $.datepicker._getInst($(this)); // $.datepicker._updateDatepicker(inst); /*$(this).datetimepicker('destroy'); InputfieldDatetimeDatepicker($(this), mintime, maxtime); $(this).datetimepicker('refresh'); */ // $(this).datetimepicker('option', {minTime: mintime, maxTime: maxtime}); } } Can you have a look and find out what the Problem is?
      InputfieldDatetime.zip
       
      Kind Regards
      Orkun
    • By teppo
      This module tracks changes, additions, removals etc. of public (as in "not under admin") pages of your site. Like it's name says, it doesn't attempt to be a version control system or anything like that - just a log of what's happened.
      At the moment it's still a work in progress and will most likely be a victim of many ruthless this-won't-work-let's-try-that-instead cycles, but I believe I've nailed basic functionality well enough to post it here.. so, once again, I'll be happy to hear any comments you folks can provide
      https://modules.processwire.com/modules/process-changelog/
      https://github.com/teppokoivula/ProcessChangelog
      How does it work?
      Exactly like it's (sort of) predecessor, Process Changelog actually consists of two modules: Process Changelog and Process Changelog Hooks. Hooks module exists only to serve main module by hooking into various functions within Pages class, collecting data of performed operations, refining it and keeping up a log of events in it's own custom database table (process_changelog.) Visible part is managed by Process Changelog, which provides users a (relatively) pretty view of the contents of said log table.
      How do you use it?
      When installed this module adds new page called Changelog under Admin > Setup which provides you with a table view of collected data and basic filtering tools See attached screenshots to get a general idea about what that page should look like after a while.
      For detailed installation instructions etc. see README.md.
       


    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




×
×
  • Create New...