- $r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo`
- WHERE `resource-id` = '%s'
- ORDER BY `width` DESC LIMIT 1",
- $resource_id
- );
- if (!$r) {
+ $photo = Photo::selectFirst(['id', 'datasize', 'width', 'height', 'type'], ['resource-id' => $resource_id], ['order' => ['width']]);
+ if (!$photo) {