//The first image as a thumbnail by laozuo.org function showThumbnail($widget) { $attach = $widget->attachments(1)->attachment; $pattern = '/\<img.*? src\=\"(.*?)\"[^>]*>/i'; if (preg_match_all($pattern, $widget->content, $thumbUrl)) { echo $thumbUrl[1][0]; } else if ($attach->isImage) { echo $attach->url; } else { echo $random; } }
<img src="<?php%20showThumbnail($this);%20?>">