diff options
Diffstat (limited to 'generators.c')
| -rw-r--r-- | generators.c | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/generators.c b/generators.c index 5eb7fde..8c8bc4e 100644 --- a/generators.c +++ b/generators.c @@ -588,6 +588,7 @@ write_html_image (TGallerySetup *setup, int i; char *s1, *s2, *s3, *s4; char *imgname, *preload_imgname; + char *title, *title_desc; char *b; gboolean res; int level; @@ -684,18 +685,52 @@ write_html_image (TGallerySetup *setup, continue; } + /* Get title and description from IPTC/EXIF/JPEG if not defined */ + title = g_strdup (item->title); + title_desc = g_strdup (item->title_description); + if (setup->use_iptc_exif && title == NULL && title_desc == NULL) { + if (exif->iptc_caption) + title = g_strdup (exif->iptc_caption); + if (exif->jpeg_comment) { + if (! title) + title = g_strdup (exif->jpeg_comment); + else + title_desc = g_strdup (exif->jpeg_comment); + } + if (exif->exif_imgdesc) { + if (! title) + title = g_strdup (exif->exif_imgdesc); +/* if (! title_desc) -- disabled + title_desc = g_strdup (exif->exif_imgdesc); */ + } + if (exif->exif_usercomment) { + if (! title) + title = g_strdup (exif->exif_usercomment); + if (! title_desc) + title_desc = g_strdup (exif->exif_usercomment); + } + /* Convert line breaks to be visible in the HTML code */ + if (title) { + str_replace (&title, "\r\n", "<br />", NULL); + str_replace (&title, "\n", "<br />", NULL); + } + if (title_desc) { + str_replace (&title_desc, "\r\n", "<br />", NULL); + str_replace (&title_desc, "\n", "<br />", NULL); + } + } /* Simple placeholders */ if (strstr (b, "<!-- $(FILE_NAME) -->")) str_replace (&b, "<!-- $(FILE_NAME) -->", imgname, NULL); - if (strstr (b, "<!-- $(TITLE) -->") && item->title) { - s1 = g_strdup (item->title); + if (strstr (b, "<!-- $(TITLE) -->") && title) { + s1 = g_strdup (title); fix_entities (&s1); str_replace (&b, "<!-- $(TITLE) -->", s1, NULL); g_free (s1); } - if (strstr (b, "<!-- $(DESCRIPTION) -->") && item->title_description) { - s1 = g_strdup (item->title_description); + if (strstr (b, "<!-- $(DESCRIPTION) -->") && title_desc) { + s1 = g_strdup (title_desc); fix_entities (&s1); str_replace (&b, "<!-- $(DESCRIPTION) -->", s1, NULL); g_free (s1); @@ -711,7 +746,6 @@ write_html_image (TGallerySetup *setup, g_free (s1); } if (strstr (b, "<!-- $(NAV_BAR) -->")) { -// s1 = g_strconcat (item->title, " (", imgname, ")", NULL); s1 = g_strdup (imgname); parent = parent_items; level = 0; @@ -882,6 +916,8 @@ write_html_image (TGallerySetup *setup, break; } free (b); + if (title) g_free (title); + if (title_desc) g_free (title_desc); } fclose (fout); |
