/** * Expand all folder aliases and return a usable URL. * Extends the aliases registered with {@link RESOURCE_MANAGER} with support * for {pic_thumb} and {pic_image}, which resolve to either the embedded * image or thumbnail for a {@link PICTURE} in the album. The identifier * following the alias can be either an ID or an image file name (e.g. * "{pic_thumb}/1304" or "{pic_thumb}/pic_file_name.jpg"). * @param string $url * @param boolean $root_override Overrides {@link $resolve_to_root} if set to * {@link Force_root_on}. * @return string */ public function resolve_file($url, $root_override = null) { $thumb_key = '{pic_thumb}'; $pic_key = '{pic_image}'; if (strpos($url, $thumb_key) !== false) { $key = $thumb_key; } else { if (strpos($url, $pic_key) !== false) { $key = $pic_key; } } if (isset($key)) { $id = substr($url, strlen($key)); if ($id && $id[0] == '/') { $id = substr($id, 1); } /* Test if it can be an id. If yes, then look up the picture. If no, then assume it's a file name and include the id as a url */ if (is_numeric($id)) { $pic_query = $this->entry_query(); $pic_query->set_type('picture'); $pic = $pic_query->object_at_id($id); if ($key == $thumb_key) { $url = $pic->full_thumbnail_name(); } else { $url = $pic->full_file_name(); } } else { $url = new URL($this->picture_folder_url()); $url->append($id); if ($key == $thumb_key) { $url->append_to_name('_tn'); } $url = $url->as_text(); } } return parent::resolve_file($url, $root_override); }