Hi,Is there a way for me to access this thumbnail in order for it to be used in a custom page?thank you
Hi,I have a table with an image field being uploaded to default folder: uploads,
I wish to resize uploaded file as thumb_[filename] into a subfolder thumbnails i have in uploads:this function works in a custom page I use
$image = $screenshot["image"];
$width = 100;
$height = 0;
ResizeFile("uploads/$image", "uploads/thumbs/tiny_$image", $width, $height);
How would I use this function to be triggered when new record is added to a specific [screenshots] table to create the thumbnail automatically in subfolder.Thank you
You may search “resizeAndSaveToFile” in this forum.
ty, the following code works:
// Row Inserting event
function Row_Inserting(?array $oldRow, array &$newRow): ?bool
{
// Enter your code here
// To cancel, set return value to false
// To skip for grid insert/update, set return value to null
/**/
echo $newRow['Image'] . "<br>";
$width = 100;
$height = 100;
$quality = 100;
$newFileName = "thumb_" . $newRow['Image'];
$overWrite = TRUE;
$idx = -1;
$this->Image->Upload->ResizeAndSaveToFile($width, $height, $quality, 'thumbnails/' . $newFileName, $overWrite, $idx);
echo $newFileName . "<br>";
return true;
}
Is there a way for me to access original image width as I thumbnail to be with same proportions as original
Make sure you have enabled the advanced setting Always keep aspect ratio (image resize), then just specify width or height (the other can be 0), the aspect ratio will be kept automatically.