Jump to content


Photo

Release: Thumbnails

Module

  • Please log in to reply
225 replies to this topic

#41 landitus

landitus

    Distinguished Member

  • Members
  • PipPipPip
  • 96 posts
  • 6

  • LocationBuenos Aires, Argentina

Posted 19 January 2012 - 08:10 AM

It seems that way. The problem is that the site is blocked by the error (white screen with error message) this is the only module installed (3rd party) is there a way to uninstall the module like this? So then I can install it again.

#42 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,530 posts
  • 859

  • LocationVihti, Finland

Posted 19 January 2012 - 08:28 AM

Try removing files from /site/assets/cache/ There are modules.*.cache files that are safe to remove. Not sure if this helps...

#43 landitus

landitus

    Distinguished Member

  • Members
  • PipPipPip
  • 96 posts
  • 6

  • LocationBuenos Aires, Argentina

Posted 19 January 2012 - 10:02 PM

Yes! that was it! Now I know that I have to clear the cache when migrating! :-[ thanks a lot!

#44 Hani

Hani

    Full Member

  • Members
  • PipPipPip
  • 60 posts
  • 11

  • LocationSanta Barbara, CA

Posted 20 January 2012 - 01:05 PM

Hey Antti - I just tried creating a CropImage field on the latest version of PW (2.2) and while the field shows up, the "Crop Setups" section (under the field where you can preview and define the crop area for the image) does not show up. Basically, it looks like a standard image field on the edit page.

I tried the following code in my template anyway:
echo $page->my_photo->eq(0)->getThumb('thumbnail');

And I get the following error:
Error Exception: Method Pageimage::eq does not exist or is not callable in this context

Any ideas? Anyone else had the same problem with this module in the latest version of PW?

#45 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 22 January 2012 - 06:45 AM

I've just encountered the same thing.

It displays as a normal image field as you say and I get none of the crop links for my configured crops next to the images.

#46 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 22 January 2012 - 10:45 AM

Fixed it. This just needs tidying up and putting into the source, but if you open InputfieldCropImage module and find the relevant function below and replace it with the code below:

protected function renderItem($pagefile, $id, $n) {
        
        $out = parent::renderItem($pagefile, $id, $n);

        $crops = $this->modules->get('ProcessCropImage')->crops;
        if (strlen($crops)>3) {
            $cropUrl = "../image-crop/";
            $cropStr = "\n\t\t\t<div class='ui-widget-content crops'><p class='description'>Thumbnails (hover to preview, click to crop)</p>". $this->_getCropLinks($crops, $cropUrl, $pagefile) . "</div>";
        }
        
        // We add our crop string at the end of the list item that holds image
        $out .= $cropStr;//str_ireplace('</li>', $cropStr, $out);

        return $out;
    }


#47 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 22 January 2012 - 12:29 PM

Hey Antti (and others) - I went ahead and made it so that the module can now accept comma-separated lists of templates per thumbnail config.

For example, in the module config, enter a new crop setup called bigthumb like this:

bigthumb,320,240,home,search

The two extra parameters on the end are templates that this is applicable to. You can keep adding templates to the list to your hearts' content, and in this case it won't show you a thumbnail option for the images field on the basic-page template since you narrowed it to a specific list.

If you want the thubmnail to be available to all templates, simply don't add any more parameters after the first three :)

The code, oddly enough, is in the same function as my last post, so change that entire function in InputCropImage.module to the following:

protected function renderItem($pagefile, $id, $n) {
		
		$out = parent::renderItem($pagefile, $id, $n);

		$crops = $this->modules->get('ProcessCropImage')->crops;
		if (strlen($crops)>3) {
			// If we've defined one or more templates for specific crops, we need to check the current page's template to see if we actually have any applicable crops to show to the user
			$page = $this->pages->get($this->input->get->id);
			$applicableCrops = array();
			$cropArray = explode("\n", $crops);
			foreach ($cropArray as $k => $v) {
				$cropItems = explode(',', $v);
				if (count($cropItems) > 3) {
					if (in_array($page->template, array_slice($cropItems, 3))) {
						$applicableCrops[] = $cropArray[$k];
					}
				} else { // Any non-template-specific crops are automatically added to the list for all cropimage fields
					$applicableCrops[] = $cropArray[$k];
				}
			}
			$applicableCrops = implode("\n", $applicableCrops);
			
			if (!empty($applicableCrops)) {
				$cropLinks = $this->_getCropLinks($crops, $cropUrl, $pagefile);
				if (!empty($cropLinks)) {
					$cropUrl = "../image-crop/";
					$cropStr = "\n\t\t\t<div class='ui-widget-content crops'><p class='description'>Thumbnails (hover to preview, click to crop)</p>". $this->_getCropLinks($applicableCrops, $cropUrl, $pagefile) . "</div>";
					// We add our crop string at the end of the list item that holds image
					$out .= $cropStr;
				}
			}
		}

		return $out;
	}

If no crops are applicable to a particular template, it simply doesn't render the thumbnails box below each image.

#48 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,530 posts
  • 859

  • LocationVihti, Finland

Posted 22 January 2012 - 04:54 PM

Ryan did send me an email and warned that there might be problems with Thumbnails module on latest build. Haven't had the time yet to see what is needed to fix it, but it seems that Pete have done the hard work and more.

Pete: if possible can you send me an pull request in Github? This way you get proper mention on your contribution.

#49 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 22 January 2012 - 04:57 PM

Happy to help :)

I'll do it tomorrow when I'm back at my computer (and can figure out GitHub again - I don't use it often enough to remember how it works ;)).

#50 Hani

Hani

    Full Member

  • Members
  • PipPipPip
  • 60 posts
  • 11

  • LocationSanta Barbara, CA

Posted 25 January 2012 - 09:12 PM

You rock, Pete! Thanks for the fix and for adding functionality to allow for crops for specific templates. Totally handy! :)

#51 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 26 January 2012 - 07:59 AM

No problem Hani - I thought it would be quite a useful addition as you don't need to see the thumbnail options where you don't need them, plus it can reduce confusion for clients too if they apply a crop and the crop tool isn't used in a particular template.

#52 Marty Walker

Marty Walker

    Sr. Member

  • Members
  • PipPipPipPip
  • 335 posts
  • 155

  • LocationKatoomba, AU

Posted 28 January 2012 - 11:25 PM

That's a great addition Pete. Thanks!

Antti, the only issue I have is not being able to see the thumbnail previews when hovering over the thumbnail names in that field.

Regards
Marty

#53 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 29 January 2012 - 06:39 AM

On top of that, I'm getting an odd error, but only on ONE site where this is used (all of them updated t the latest version, only one showing the error):

Notice: Undefined variable: cropUrl in C:\xampp\htdocs\blah\site\modules\InputfieldCropImage\InputfieldCropImage.module on line 48

#54 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 29 January 2012 - 06:58 AM

Okay, looks like I took out a bit of code accidentally which causes my error.

In InputfieldCropImage.module, before this line:

$page = $this->pages->get($this->input->get->id);

add this

$cropUrl = "../image-crop/";

I don't think this has anything to do with the hover not working to preview thumbnails though - not sure what that is to be honest, possibly something with a newer version of jQuery maybe? I can't figure it out though it is affecting my PW 2.2 site.

I'll commit my latest code change shortly and do another pull request Antti.

#55 Hani

Hani

    Full Member

  • Members
  • PipPipPip
  • 60 posts
  • 11

  • LocationSanta Barbara, CA

Posted 29 January 2012 - 11:24 AM

the only issue I have is not being able to see the thumbnail previews when hovering over the thumbnail names in that field.


Marty - do you happen to have the HelperFieldLinks module installed? If so, the problem might be something with this part of the module's css.

.ui-widget-content{
overflow:hidden; /*clear floats*/
}

If you do have it installed, you can comment that out. I don't think there's a significant problem doing that. From what I saw, the helper link to the field/template that appears below the field simply doesn't have the proper spacing below it.

#56 Marty Walker

Marty Walker

    Sr. Member

  • Members
  • PipPipPipPip
  • 335 posts
  • 155

  • LocationKatoomba, AU

Posted 29 January 2012 - 05:34 PM

Marty - do you happen to have the HelperFieldLinks module installed?


Hi Hani,

No I don't have that one installed. I'm sure it's just something small that's causing it. To be expected with a new version of PW :)

Regards
Marty

#57 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,530 posts
  • 859

  • LocationVihti, Finland

Posted 29 January 2012 - 05:46 PM

I'll hope to find time to take a look at this. I have test case and can repeat this. With quick look I couldn't find what is causing it. JS is not throwing errors, so I think it is changed markup somewhere or some new styles that is causing problems. Probably a quick fix, but now heading to a bed.

#58 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 30 January 2012 - 02:31 AM

No problem Antti, and apologies in advance if it was something I did! ;)

#59 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1764

  • LocationSH, Switzerland

Posted 30 January 2012 - 03:39 AM

I've checked this one out on my local PW2.2 isntall. I get the same problem with the hover not working.

I fixed that one by changing the InputfieldCropImage.js a little. The live hover event wasn't working. I changed it from "mouseenter" to "mouseover", and it's working now.

I'm not sure about github. I have the repo local and commited the fix just now, but I don't know if it gets commited or apeisa needs to pull the commit first...

So heres the code for those interested:



$(document).ready(function() {

    $("a.crop").live("hover", function(e) {
        if( e.type === 'mouseover') {
            url = $(this).data('thumburl') + "?timestamp=" + new Date().getTime();
            $(this).append("<img style='position: absolute; z-index: 999;' src="+url+" />");
        }
        else {
            $(this).find("img").remove();
        }
    });
    
    $(".InputfieldCropImage .InputfieldFileList").live('AjaxUploadDone', function() {
        console.log("it should");
        $("a.InputfieldFileLink", $(this)).fancybox(); 
    }); 
    
    /* Modal disabled, cropping huge images is very difficult with modals
    $("a.crop").live("click", function() {
        var url = $(this).attr('href');
        var windowHeight = $(window).height() - 120; 
        var windowWidth = $(window).width() - 120; 
        $iframe = $('<iframe id="pwimage_iframe" width="100%" frameborder="0" src="'+url+'"></iframe>');
        $iframe.parent().css('position', 'fixed').end().dialog({
                    title: "Crop Image", 
                    height: windowHeight,
                    width: windowWidth,
                    position: [60, 60], 
                    modal: true,
                    overlay: {
                        opacity: 0.7,
                        background: "black"
                    }
                }).width(windowWidth).height(windowHeight);
        return false;
    });
    */
});

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


#60 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,530 posts
  • 859

  • LocationVihti, Finland

Posted 30 January 2012 - 05:06 AM

Soma, thanks for the fix! Have you tested that on Firefox? See this: http://processwire.c..._5253#entry5253





Also tagged with one or more of these keywords: Module

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users