Jump to content


Photo

Page List Image Label

Module

  • Please log in to reply
5 replies to this topic

#1 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 08 June 2012 - 03:17 PM

Marty requested and sponsored a new module little while ago.
http://processwire.c...t-image-option/

I just wanted to create a separate release thread. Many thanks to Marty for sponsoring and making this possible. This just shows how great this community is. :)

So here it is the Page List Image Label module. It enables you to add thumbnails of images from the pages in the admin page tree.

Download:
https://github.com/s...eListImageLabel

After installing you can define some options if you like to specify a width/height of the thumbnails and also change the look with some css options, like border padding and background color.

All you need to do to enable it, is add the name (i.e. images) of the image field you have on the template to the custom label option in the advanced template settings. It works for single, multiple and cropimage image field types. If multiple images field it will always take the first image from the stack. Have fun!

A screenshot of it in production.
PastedGraphic-1.png

@somartist | modules created | support me, flattr my work flattr.com


#2 SiNNuT

SiNNuT

    Sr. Member

  • Members
  • PipPipPipPip
  • 367 posts
  • 232

Posted 09 June 2012 - 04:34 AM

Great stuff!

#3 arjen

arjen

    Sr. Member

  • Members
  • PipPipPipPip
  • 340 posts
  • 126

  • LocationHoogeveen, The Netherlands

Posted 24 September 2012 - 12:55 PM

Thanks, Soma. Great module. Finally got a chance to use this in a new project.
work will always be the curse of the drinking classes...

#4 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 18 November 2012 - 02:21 PM

Ryan, the image generation stops working for crop_images (apeisa modules thumbnails) with dev branch and file protection enabled.

I can see that somehow the new sizing of the thumbnail returns a protected url like /path/to/page/-/ But can't see how it would be possible to fix. It works with normal image fields.

Code that is responsible is.


// if image field is of type cropimage (thumbnails module)
if($this->fields->get($field)->type == "FieldtypeCropImage"){
  if(count($v)){
    $thumb_url = $v->first()->getThumb($subfield);
    $thumb_url = $v->url . $this->resizeThumb($v, $thumb_url, $size);
  }
} else { // all normal image fields
  if(count($v)){
    $thumb_url = $page->$field->first()->size($size[0],$size[1])->url;
  }
}

And the resize


private function resizeThumb($field, $thumb_url, $size){
  $thumb_path = $this->config->paths->root . $thumb_url;
  $filename = $size[0] . "x" . $size[1] . "_" . basename($thumb_url);
  $thumb_path_new = $field->path . $filename;
  if(@copy($thumb_path, $thumb_path_new )){
    $sizer = new ImageSizer($thumb_path_new);
    $sizer->resize($size[0],$size[1]);
    return $filename;
  } else return false;

}

@somartist | modules created | support me, flattr my work flattr.com


#5 ryan

ryan

    Hero Member

  • Administrators
  • 5,812 posts
  • 3141

  • LocationAtlanta, GA

Posted 20 November 2012 - 01:05 PM

The problem here is that resizeThumb()'s implementation assumes that one can construct the server path to the file from the URL (see the first line in that function). But the URL and disk path can be very different things. You may be able to fix it by replacing the first line in that function with this:

$thumb_path = $field->path() . basename($thumb_url);


#6 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 20 November 2012 - 03:03 PM

The problem here is that resizeThumb()'s implementation assumes that one can construct the server path to the file from the URL (see the first line in that function). But the URL and disk path can be very different things. You may be able to fix it by replacing the first line in that function with this:

$thumb_path = $field->path() . basename($thumb_url);


You're my hero! Yes it seems this was it. I fixed it and while at it added check for if the image already exists to not create it everytime. Commited to the source. It's now on 1.0.2.

Thanks

@somartist | modules created | support me, flattr my work flattr.com






Also tagged with one or more of these keywords: Module

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users