-function admin_images_main_display($id) {
- $data = db_get_assoc('cms_images', 'id,'.ADMIN_IMAGES_DB_FIELDS, 'where id=%i', $id);
- if(!$data) {
- message("Error: Broken Link (Image #$id not found)");
- return './admin_images';
- }
-
- # Find pages that have this image on it
- if($data['image']) {
- $references = db_get_assocs('cms_pages', 'title,filename', 'where content like "%%%s%%" order by concat(nav_title,title)', substr(enc_image_src($data['image']), 0, -4)); # FIXME test that this works for smaller images
- if($references) {
- $data['references'] = array(
- 'data' => $references,
- 'count' => count($references));
- }
- }
-
- # display smaller versions with instructions and example code
- $smaller == array();
- if($data['image'] && $data['sizes']) {
- $big_src = enc_image_src($data['image']);
- $row = explode("\n", $data['sizes']);
- foreach($row as $max_hw) {
- $max_hw = format_width_height($max_hw);
- if($max_hw == '') {
- continue;
- }
- list($max_width, $max_height) = explode('x', $max_hw);
- $src = str_replace('.', "-$max_width-$max_height.", $big_src);
- $dimensions = image_dimensions($src);
- if($dimensions) {
- list($width, $height) = explode('x', $dimensions);
- } else {
- $width = $max_width;
- $height = $max_height;
- }
-
- $smaller[] = array(
- 'src' => $src,
- 'max_width' => $max_width,
- 'max_height' => $max_height,
- 'width' => $width,
- 'height' => $height);
- }
- }
- if($smaller) {
- $data['smaller'] = $smaller;
- } else {
- tem_set('no_sizes');
- }
-
- tem_set('display', $data);
-}
-