+ /**
+ * Construct a photo array for an external resource image
+ *
+ * @param string $url Image URL
+ * @param int $uid User ID of the requesting person
+ * @param string $mimetype Image mime type. Is guessed by file name when empty.
+ *
+ * @return array
+ * @throws \Exception
+ */
+ public static function createPhotoForExternalResource($url, $uid = 0, $mimetype = '')
+ {
+ if (empty($mimetype)) {
+ $mimetype = Images::guessTypeByExtension($url);
+ }
+
+ $fields = self::getFields();
+ $values = array_fill(0, count($fields), "");
+
+ $photo = array_combine($fields, $values);
+ $photo['backend-class'] = ExternalResource::NAME;
+ $photo['backend-ref'] = json_encode(['url' => $url, 'uid' => $uid]);
+ $photo['type'] = $mimetype;
+ $photo['cacheable'] = true;
+
+ return $photo;
+ }