diff options
| -rw-r--r-- | src/generators.c | 80 | ||||
| -rw-r--r-- | src/items.c | 4 | ||||
| -rw-r--r-- | src/setup.c | 4 |
3 files changed, 42 insertions, 46 deletions
diff --git a/src/generators.c b/src/generators.c index b83382a..1ecb3c6 100644 --- a/src/generators.c +++ b/src/generators.c @@ -206,23 +206,29 @@ get_image_paths (TGallerySetup *setup, if (page_img_dst) *page_img_dst = NULL; - /* ignore combinations that are not valid */ - if ((items->type == GALLERY_TYPE_INDEX && ! image_size->is_thumbnail) || - (image_size->is_thumbnail && item->hidden) || - (image_size->is_thumbnail && items->type == GALLERY_TYPE_INDEX && (item->thumbnail == NULL || strlen (item->thumbnail) == 0))) + if (full_img_src == NULL && image_size == NULL) return; s1 = NULL; - if (image_size->is_thumbnail && items->type == GALLERY_TYPE_INDEX) - s1 = item->thumbnail; - - if (s1 == NULL && item->image_sizes != NULL) - s1 = g_hash_table_lookup (item->image_sizes, image_size->name); - - /* go through the fallback */ - while (s1 == NULL && image_size->fallback_size != NULL) { - image_size = lookup_image_size_for_name (setup, image_size->fallback_size); - s1 = item->image_sizes ? g_hash_table_lookup (item->image_sizes, image_size->name) : NULL; + /* image_size == NULL means return real image source path */ + if (image_size) { + /* ignore combinations that are not valid */ + if ((items->type == GALLERY_TYPE_INDEX && ! image_size->is_thumbnail) || + (image_size->is_thumbnail && item->hidden) || + (image_size->is_thumbnail && items->type == GALLERY_TYPE_INDEX && (item->thumbnail == NULL || strlen (item->thumbnail) == 0))) + return; + + if (image_size->is_thumbnail && items->type == GALLERY_TYPE_INDEX) + s1 = item->thumbnail; + + if (s1 == NULL && item->image_sizes != NULL) + s1 = g_hash_table_lookup (item->image_sizes, image_size->name); + + /* go through the fallback */ + while (s1 == NULL && image_size->fallback_size != NULL) { + image_size = lookup_image_size_for_name (setup, image_size->fallback_size); + s1 = item->image_sizes ? g_hash_table_lookup (item->image_sizes, image_size->name) : NULL; + } } /* we have reached our target image size, s1 == NULL means the image should be resized from the source image */ @@ -237,19 +243,21 @@ get_image_paths (TGallerySetup *setup, if (full_img_src) *full_img_src = g_build_filename (path_info->src_dir, s1, NULL); - target_image_dir = g_strdup_printf ("%s%s", TARGET_IMAGE_DIR_PREFIX, image_size->name); - s2 = g_path_get_basename (s1); - if (image_size->is_thumbnail) { - s3 = g_strdup_printf (THUMBNAIL_NAME_FORMAT, get_item_index (items, item), s2); + if (image_size) { + target_image_dir = g_strdup_printf ("%s%s", TARGET_IMAGE_DIR_PREFIX, image_size->name); + s2 = g_path_get_basename (s1); + if (image_size->is_thumbnail) { + s3 = g_strdup_printf (THUMBNAIL_NAME_FORMAT, get_item_index (items, item), s2); + g_free (s2); + s2 = s3; + } + if (full_img_dst) + *full_img_dst = g_build_filename (path_info->dest_dir, target_image_dir, s2, NULL); + if (page_img_dst) + *page_img_dst = g_build_filename (target_image_dir, s2, NULL); g_free (s2); - s2 = s3; + g_free (target_image_dir); } - if (full_img_dst) - *full_img_dst = g_build_filename (path_info->dest_dir, target_image_dir, s2, NULL); - if (page_img_dst) - *page_img_dst = g_build_filename (target_image_dir, s2, NULL); - g_free (s2); - g_free (target_image_dir); } @@ -711,7 +719,6 @@ get_img_exif_data (TGallerySetup *setup, TImageSize *image_size) { ExifData *exif; - TImageSize *orig_image_size; gchar *img_orig_src; gchar *img_dst; gchar *s; @@ -726,20 +733,17 @@ get_img_exif_data (TGallerySetup *setup, g_free (s); } - /* Get EXIF data from the original image */ + /* Get EXIF data from the source image */ if (exif == NULL) { img_orig_src = NULL; - orig_image_size = lookup_image_size_for_name (setup, "original"); - if (orig_image_size) { - get_image_paths (setup, items, item, path_info, orig_image_size, &img_orig_src, NULL, NULL); - if (img_orig_src != NULL && g_access (img_orig_src, R_OK) == 0) - exif = read_exif (img_orig_src); - /* -- silently succeed - if (exif == NULL) - log_error ("write_html_image: error getting exif data from file \"%s\"\n", img_orig_src); - */ - g_free (img_orig_src); - } + get_image_paths (setup, items, item, path_info, NULL, &img_orig_src, NULL, NULL); + if (img_orig_src != NULL && g_access (img_orig_src, R_OK) == 0) + exif = read_exif (img_orig_src); + /* -- silently succeed + if (exif == NULL) + log_error ("write_html_image: error getting exif data from file \"%s\"\n", img_orig_src); + */ + g_free (img_orig_src); } /* Try destination image size instead, though it might have the metadata stripped */ diff --git a/src/items.c b/src/items.c index 27ab57e..d475f91 100644 --- a/src/items.c +++ b/src/items.c @@ -513,8 +513,6 @@ get_album_titles (const gchar *filename, gchar **title, gchar **description, gch *thumbnail = xml_file_get_node_attribute (xml, "/gallery/items/item[1]/thumbnail", "src"); if (! *thumbnail) *thumbnail = xml_file_get_node_attribute (xml, "/gallery/items/item[1]", "src"); - if (! *thumbnail) - *thumbnail = xml_file_get_node_attribute (xml, "/gallery/items/item[1]", "preview"); } xml_parser_free (xml); @@ -577,8 +575,6 @@ get_item_target_filename (TIndexItem *item) const gchar *s; s = item->path; - if (s == NULL && item->image_sizes) - s = g_hash_table_lookup (item->image_sizes, "preview"); if (s == NULL) return NULL; diff --git a/src/setup.c b/src/setup.c index 3d1ff2e..b2cd800 100644 --- a/src/setup.c +++ b/src/setup.c @@ -463,10 +463,6 @@ validate_design_setup (TGallerySetup *setup) fprintf (stderr, "design validation error: no image size defined\n"); return FALSE; } - if (lookup_image_size_for_name (setup, "original") == NULL) { - fprintf (stderr, "design validation error: mandatory \"original\" image size not defined\n"); - return FALSE; - } for (l = g_list_first (setup->design->image_sizes); l; l = g_list_next (l)) { image_size = l->data; g_assert (image_size != NULL); |
