Jump to content

CroppableImage


horst

Recommended Posts

This doesn't help me much because I have tested it today with PW 2.5.19 dev and it works well with caching here.  ??

Maybe there is something different with previously installed and used fields, (before upgrading PW to 2.5.18 or 2.5.19) in regard to new created fields?

Another thing you may test is a check for forceNew just before you call the getCrop:

$forceNew = isset($config->imageSizerOptions['forceNew']) ? $config->imageSizerOptions['forceNew'] : false;
$forceNew = $forceNew ? '<p>forceNew is ON</p>' : '<p>forceNew is off</p>';
$page->imageCrop->getCrop('test')->url;
Link to comment
Share on other sites

Acutally it's an upgrade from 2.5.6 to 2.5.19 because I wanted to use Croppable Image.

Deleted index.php and wire folder --> replaced them with 2.5.19 dev

In my config there are no imageSizerOptions, so for this purpose I've added it.

'forceNew' => true    ---> resulted in your suggestion: forceNew is on

'forceNew'=> false    ---> forceNew is off

Even with 'off', thumbnails are being regenerated on front-end... [didn't check back-end]

Link to comment
Share on other sites

what is the name of your imagefield? does it contain mixed chars, I mean upper and lower case? If so, can you try it with a fieldname that only has lowercase chars?

As I said above for me the caching works as expected with PW 2.5.19

Link to comment
Share on other sites

The name of my imagefield is 'images', I never use upper case, all my fields [regardless type] are lower case.

I remember I had a similar set-up with following specs:

PW 2.5.18

 FieldtypeCroppableImage 0.8.2
 InputfieldCroppableImage 0.8.2
 ProcessCroppableImage 0.8.4

Guess what, the problem isn't there... 

Maybe tomorrow or somewhere soon I'll upgrade this one to 2.5.19 see what that gives... Or if you suggest something else?

Other set-up

PW 2.5.19

 FieldtypeCroppableImage 0.8.3
 InputfieldCroppableImage 0.8.3
 ProcessCroppableImage 0.8.4
 
Maybe this gives you some insights...
 
 
Link to comment
Share on other sites

How exactly do you go about looping through thumbnails? I have an image field called f_multi_image which allows multiple image attachments.
 
I would have thought it was something like this, but obviously it's not right.
 

$gallery = $page->f_multi_image->getCrop('gallery');

foreach($gallery as $image){
  echo "<img src='{$image->url}' alt='{$image->description}' />";
}
Link to comment
Share on other sites

I don't know what .PagefilesManagerxxx is. CroppableImages doesn't use it or interacts with it. ImageSizer also don't.

I think it stays there from a upgrade or something? It is preceded by a dot, what is a sign that it isn't read from any PW object. It is a backup directory. (That's all I can think of)

Link to comment
Share on other sites

In new PW dev the croppable image has broken layout when uploading image. After saving the layout seems ok.

The new image edit function isn't there as there seems to be some rewrite of markup. Could this be possible to have it working together?

Link to comment
Share on other sites

The new image edit function isn't there as there seems to be some rewrite of markup. Could this be possible to have it working together?

I could imagine the module hooking into the new "variations" modal window or a own dedicated modal like the core one. I never really liked the fact, that the imagefields presentation was changed. With Thumbnails I had breaking admin theme styles and now it's a new core function made unavailable. 

Additionally, it would be nice if CroppableImage could also recrop api generated crops from the variations modal. Of course only the ones restricted in height and width.

Link to comment
Share on other sites

  • 1 month later...

Is this the proper way to call a crop called Staff-Photo in a field called Images?

<?php
$peoples = $pages->find ("template=team-detail");
foreach ($peoples as $person){
echo"<a href='{$person->url}'><img src='{$person->Images->getCrop('Staff-Photo')}\'></a>";
}
?>

I'm getting an error as follows.

Error: Exception: Method Pageimages::getCrop does not exist or is not callable in this context (in /Users/peterknight/Sites/Eden/wire/core/Wire.php line 326)

#0 /Users/peterknight/Sites/Eden/site/templates/team-overview.php(50): Wire->__call('getCrop', Array)

I'm not sure if it's my syntax or a problem with my install. 

Croppable Image is installed properly and the pages I am calling in my selector all have an image with Staff-Photo crop applied.

Link to comment
Share on other sites

Your images field in the template 'team-detail' is probably not limited to '1', so I guess in this case you might try

echo '<a href="'.$person->url.'" title="'.$person->title.'"><img src="'.$person->Images->first->getCrop('Staff-Photo')->url.'" alt="'.$person->title.'" /></a>';
Link to comment
Share on other sites

@videokid

I didn't think this mattered as you can only have one instance of a crop on any one Images field.

Sure, you can have many differently sized crops but you can only cropped image based on the Staff-Crop setting?

Clearly I was wrong as your code works (thanks) although I modified it slightly yo my own requirements

<?php 
   echo"<div class='row'>";
   $peoples = $pages->find ("template=team-detail");
   foreach ($peoples as $person){
   echo"<div class='small-6 medium-4 columns'>";
   echo"
     <div class='person-wrapper grid'>
       <div class='service-img'>
       <a href='{$person->url}'>
          <img src='{$person->Images->first->getCrop('Staff-Photo')->url}'>
       </a>
       </div>
       <strong>{$person->title}, {$person->Qualification}</strong><br/>
       {$person->Role}
     </div>";
     echo"</div>";
     }
     echo"</div>";
     ?>
Link to comment
Share on other sites

Hi Peter, thanks for reporting that.

I have looked into that, but it seems it is related to PW core, not croppableimages fields in special, or maybe I have to transform the fieldname to lowercase at some point in the modules code.

  • I have created a new field of type text and given it a capitalized name: My_New_Field
  • The table was created as: field_my_new_field
  • In the fields table it is registered with name = My_New_Field

I will further test it with core images field and others and look how it is handled there.

So, when creating a new field you can read in the description of the Name* input:

But one can enter uppercase letters. Is this intended or should it be sanitized by PW to a-z_0-9 ?

Hey Horst,

I tried to save my thumbnail settings and got this error:

Session: Table 'xxx.field_sliderImage' doesn't exist SELECT pages_id,count(pages_id) FROM field_sliderImage GROUP BY pages_id ORDER BY pages_id

So I looked into your code and found this one in FieldtypeCroppableImage.module:339:

$TABLE = 'field_' . $field->name;  // TODO: name to lowercase 

To answer your question: Probably. :-)

Currently working with a hoster who's obviously case sensitive. I saw the table name was field_sliderimage (all lowercase) and edited your code to this:

$TABLE = 'field_' . strtolower($field->name);  // TODO: name to lowercase  N: Yes! ;-)

And yep, it worked!

noodles

  • Like 1
Link to comment
Share on other sites

Great to read it works! Although I'm not really sure if I understand what you exactly mean here... 

Modify away! :-)

What I mean is (and this might be a bug)....

An image field of mine has several images. Unless I crop the very first image in the image field, the selector won't work.

I like to let my editor choose which image to crop. That image could be the second or third image.

With this ... 

<img src='{$person->Images->first->getCrop('Staff-Photo')->url}'>

there seems to be a quirk where PW isn't looking for the very first instance of 'Staff Photo'. It's looking for the very first image. If that image has no cop applied, I get an error.

The alternative it to setup a special image field solely for each crop but that shouldn't be necessary ?

Link to comment
Share on other sites

Your explanation makes no sense to me actually ... :-/ Probably I'm not getting what exactly you're trying to achieve...

On top, AFAIK, every image is cropped when using CroppableImage, unless I'm really wrong here...

if not using 'first' or eq($n), then I guess  you use foreach($person->Images as $img)

<img src='{$img->getCrop('Staff-Photo')->url}'>

but then you'll get all of them.... and the cropped version...

Link to comment
Share on other sites

is it possible to select the cropped images from my CKeditor image select popup?

I if I was going to try to implement it the correct module might be: /wire/modules/Process/ProcessPageEditImageSelect/ProcessPageEditImageSelect.module.  Would  copying that to /site/modules/, and modifying it be the sensible way to allow cropped images to be selected from CKeditor? Or is there already a setting that already exists for showing more images than just the original (uncroped images) in CKeditor?

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...