Test Images are valid and exists

Send Snippet To: Save this snippet to Code Collector Pro -- view all balzan's snippets
language: PHP
license: Other

Code for Snippet:

// Also resizes images in Silverstripe
public function getExportFields() {
		$url = Director::absoluteBaseURL();
		$image = $this->getComponent("Photo");
		$device = $this->getComponent("Device");
		$thumbImage = $image->CMSThumbnail();
		return array(
			"imageURL" => ($image->exists()) ? $image->getAbsoluteURL(): null,
			"thumbImageURL" => ($thumbImage) ? $thumbImage->getAbsoluteURL(): null,
			"screenImageURL" => ($image->exists()) ? $image->setWidth(400)->getAbsoluteURL(): null,
			"created" => $this->getField("Created") ,
comments powered by Disqus


Link to this snippet:

Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 129
Date Added: 2015-12-15 23:39:44
Last Modified: 2016-07-05 23:42:18

Web Analytics