Jump to content

How can invoke ->size() for a image in file field type


picarica
 Share

Recommended Posts

so hello there i have fiel field type i have lots of stuff there, and also an image i can easily get image from that field using

                                                  

													$options = array('quality' => 85, 'upscaling' => true, 'cropping' => 'north', 'sharpening' => 'medium');
													$word = ".png";
													// Test if string contains the word 
													foreach($childgames->subor_hry as $file) {
														if(strpos($file, $word) !== false){
															/* $imger = $file->size(473, 266, $options); */
															echo $file;
													  		/* echo $file->url; */
														}
													}	

so i get the fiel i tried invoking size on it like the commented out part and it doesnt work i get error Oh snizzle… Error:     Exception: Method Pagefile::size does not exist or is not callable in this context (in

what am i doing wrong? can you guys help me by all logic this should work

Link to comment
Share on other sites

2 minutes ago, Gideon So said:

Hi @picarica,

Welcome to the forum.

size() method only applicable to image field but not file field.

Gideon

ye welp, its still an image, so ill probably have to make some sort of hook to put image into image field and then output them, well thanks for confirmation

Link to comment
Share on other sites

  • 3 weeks later...
On 3/15/2021 at 8:37 PM, Macrura said:

This should do it.

i have been trying this for a while and what even is imageSizer? is it like a hook ? if so i get error everytime i try ti save it
    ProcessPageEdit: Unable to read: /site-hry/assets/files/1027/flash_fishy_screenshot.png

and when i put it into template i get different error do i understand it incorrectly ? i have this setup

  $word = ".png";
    foreach($page->subor_hry as $file) {
        if(strpos($file, $word) !== false){
      		$image = new Pageimage($page->images_thumb, $file->url);
        }
    }

 

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

×
×
  • Create New...