Jump to content

Thumbnails of images in TinyMCE


Nico Knoll
 Share

Recommended Posts

  • 2 months later...

I can see using a browser resize where a max width or height is specified, but am not so sure if it's good to have ProcessWire going and creating multiple new thumbnail files just so they can be selected in the admin. Perhaps a good balance would be to display the ones with thumbnails where the 'admin thumbnails' option is selected with the image field, and just use the same thumbnail.

Link to comment
Share on other sites

I think that'd be the way to do it Ryan - it covers every website I've done so far as they all have admin thumbnails turned on.

Obviously other people's scenarios will vary but that would cater for the majority I think.

Link to comment
Share on other sites

Here is my hack to do such thing easily :

I edited the ProcessPageEditImageSelect.module to add two protected vars : $thumbWidth and $thumbHeight and i change the ___execute() function like so :

      	 foreach($images as $image) {
               //$width = $image->width();
               $thumb = $image->size($this->thumbWidth, $this->thumbHeight);

               if($width > $this->maxImageWidth) $width = $this->maxImageWidth;
               $out .= "\n\t<li><a href='./edit?file={$image->basename}&modal=1&id={$this->page->id}&winwidth=$winwidth'>" .
                   "<img src='{$thumb->url}' width='{$this->thumbWidth}' alt=\"{$image->description}\" /></a></li>";
           }

i used the size() function to change the image width and height, to create a thumbnail and instead of using $image->url i use $thumb-url

Just after that, i change my css to make <li> element float in order to get a grid of elements :


#select_images li {

float: left;
margin: 0 5px 5px 0;
}

see the attached image for an example of use.

There is just a one problem, if the picture is smaller than the thumbnail width and height, the size function will make a pixelazed version wich isn't good, in such case, the function have to add a blank space to make a correct thumb.

post-393-0-87680900-1328926655_thumb.png

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...