Forum

Thread tagged as: Question, Api, Events

Get the name of the image just uploaded - so we can create a webp format with ph...

Been trying to do the above with a small app and an admin.php. I can detect the image upload with a on('assets.create_image' event which makes available a PerchSystemEvent object. If I printr the object to a file I can see all the data - including image name for the thumbnail from which the original file name can be derived. However it seems that the information within $Event->subject->details is private and cannot be accessed directly. (I can for example get the userHash).

Any suggestions? Could you also point me at the code within Perch that handles the image uploading?

Thanks

Peter

Peter Lawless

Peter Lawless 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

$Event->subject should be an instance of PerchAssetFile.

$Asset = $Event->subject;
echo $Asset->file_path;
Drew McLellan

Drew McLellan 2638 points
Perch Support

I'd be interested to know how you get on generating WebP files with PHP. I looked into this for Perch and concluded that PHP wasn't really ready for WebP yet.

Thanks Drew - finger trouble on my part. I misinterpreted what printr was telling me and was going for $Event->subject->details['file_path']. Afraid I very much pre-date Objects!

Will let you know how the PHP webp works out. Intend to use "imagewebp" function in 5.5.

Regards

Peter

Drew McLellan

Drew McLellan 2638 points
Perch Support

Good luck!

Hi Drew

imagewebp did not produce a valid image format on any of 3 test images. There is a known bug in libwebp (https://bugs.php.net/bug.php?id=66590). It seems it has been fixed very recently but an upgrade to PHP 5.6.11 on my Ubuntu 12.04 server did not resolve the problem.

Regards

Peter

Drew McLellan

Drew McLellan 2638 points
Perch Support

And there I was hoping you might be blazing a trail. Bad luck. Maybe in another 6 months...