Jump to content

back to image basics day!


davo
 Share

Recommended Posts

Can't work out why my thumbnail resizing here doesn't work. It's probably something very obvious (as usual)

<?php 

/**
 * Page template
 *
 */

include("./head.inc"); 

echo $page->body;

$contestantarray = $pages->find("template=user"); //get all the users

$contestants = $contestantarray->findRandom(2); //grab two contestants

foreach ($contestants as $contestant) {
		$lineup = $contestant->profile_image;        //create the contestant
		$thumb_contest = $lineup->size(50, 50);      //create a thumbnail
		echo "<img src='{$thumb_contest->url}{$thumb_contest}'><br /> " ; //output the thumbnail
}

include("./foot.inc"); 

errror:

Error: Exception: Method Pageimages::size does not exist or is not callable in this context (in /var/www/clients/client15/web43/web/wire/core/Wire.php line 320)

#0 /var/www/clients/client15/web43/web/site/templates/contest.php(19): Wire->__call('size', Array)
#1 /var/www/clients/client15/web43/web/site/templates/contest.php(19): Pageimages->size(50, 50)
#2 /var/www/clients/client15/web43/web/wire/core/TemplateFile.php(140): require('/var/www/client...')
#3 [internal function]: TemplateFile->___render()
#4 /var/www/clients/client15/web43/web/wire/core/Wire.php(359): call_user_func_array(Array, Array)
#5 /var/www/clients/client15/web43/web/wire/core/Wire.php(317): Wire->runHooks('render', Array)
#6 /var/www/clients/client15/web43/web/wire/modules/PageRender.module(337): Wire->__call('render', Array)
#7 /var/www/clients/client15/web43/web/wire/modules/PageRender.module(337): TemplateFile->render()
#8 [internal function]: PageRender->___renderPage(Object(HookEvent))
#9 /var/www/clients/client15/web43/web/wire/core/Wire

This error message was shown because you are logged in as a Superuser. Error has been logged. 
Link to comment
Share on other sites

Is your profile_image field a single image field? If not, you can either change this in the admin area by setting the maximum of files for this field to 1. If not, you could access the "first" image with the first() method.

$thumb_contest = $contestant->profile_image->first()->size(50,50);

If this doesn't work you might have to check if you have the right pages in the PageArray $contestants.

  • Like 1
Link to comment
Share on other sites

It would be an interesting statistic to see how many times the 'problem' about single/multiple image and file fields has come up on the forum :)

I think it will happen less from now on :)

post-88-0-45530100-1410028010_thumb.png

  • Like 2
Link to comment
Share on other sites

It would be an interesting statistic to see how many times the 'problem' about single/multiple image and file fields has come up on the forum :)

 Probably a similar number to that of the number of posts I have made!

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