Active
Project:
Computed Field
Version:
7.x-1.0-beta1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 May 2012 at 09:57 UTC
Updated:
14 Dec 2012 at 15:20 UTC
Is it possible to return an image in a computed field?
I would like to use it to scale an image but I got the error
Recoverable fatal error: Object of class stdClass could not be converted to string in DatabaseStatementBase->execute() (line 2136 of /home/xxx/includes/database/database.inc).
My computed field code is:
$file = file_load($entity->uc_product_image['und'][0]['fid']);
$image = image_load($file->uri);
//$scaled = image_scale($image, 200);
image_save($image);
$entity_field[0]['value'] = $image;
Comments
Comment #1
EmmyS commentedAssuming that $file->uri is actually returning something valid, try this:
Comment #2
GBurg commentedThis post helped me to create a default image for a passport photo (pasfoto), if no photo is set. The image is dependable on your gender (geslacht), male (man) or female (vrouw). So it first checks if the pasfoto is already set (it is an image field cropped). If not, it builds a default value.