Fog
Fog

Fog

Weather and Sky

Menu
  • Home
  • Weather and Sky
    • Lightning
    • Supercells
    • Tornadoes
    • Thunderstorms
    • Rainbows
    • Dust Devils
    • Floods
    • Wave Clouds
    • Sunrise/Sunset
    • Fog
  • Astrophotography
    • Moon
    • Deep Sky Objects
    • Comets
    • Aurora
    • Rockets
    • Eclipses
    • Telescopes
    • Miscellaneous Astro
  • Earth and Water
    • Canyons
    • Mountains
    • Rocks
    • Sand & Desert
    • Snow & Ice
    • Trees
    • Water
  • About the Photographer
  • Copyright
  • Photo Blog
Fog
Fog
Fog
Fog
    ' . trim(file_get_contents($caption_file)); } // Initialise variables $image_title = ''; $image_description = ''; // 2. Check Exif metadata (Title and Description fields) $exifData = @exif_read_data($image_path, 'IFD0'); if ($exifData !== false) { if (isset($exifData['XPTitle']) && !empty(trim($exifData['XPTitle']))) { $image_title = '' . trim($exifData['XPTitle']); } if (isset($exifData['ImageDescription']) && !empty(trim($exifData['ImageDescription']))) { $image_description = '' . trim($exifData['ImageDescription']); } } // 3. Check IPTC metadata (Title and Caption fields) $size = getimagesize($image_path, $info); if (isset($info['APP13'])) { $iptc = iptcparse($info['APP13']); if (!empty($iptc['2#005'][0])) { // 2#005 is the IPTC object name (title) $image_title = '' . trim($iptc['2#005'][0]); } if (!empty($iptc['2#120'][0])) { // 2#120 is the IPTC caption (description) field $image_description = '' . trim($iptc['2#120'][0]); } } // 4. Check XMP metadata (Title and Description fields) $xmpData = file_get_contents($image_path); if (preg_match('/(.*?)<\/dc:title>/s', $xmpData, $title_match)) { $image_title = '' . trim(strip_tags($title_match[1])); } if (preg_match('/(.*?)<\/dc:description>/s', $xmpData, $desc_match)) { $image_description = '' . trim(strip_tags($desc_match[1])); } // Format the output with user-specified HTML tags $formatted_title = $image_title ? "<$title_tag>$image_title" : ''; $formatted_description = $image_description ? "<$desc_tag>$image_description" : ''; // 5. Determine what to return based on user preference if ($caption_type === 'title' && !empty($formatted_title)) { return $formatted_title; } elseif ($caption_type === 'description' && !empty($formatted_description)) { return $formatted_description; } elseif ($caption_type === 'both') { if (!empty($formatted_title) && !empty($formatted_description)) { return $formatted_title . $separator . $formatted_description; } elseif (!empty($formatted_title)) { return $formatted_title; } elseif (!empty($formatted_description)) { return $formatted_description; } } // 6. Fallback to formatted filename return "<$title_tag>" . ucfirst($filetitle) . ""; } function getImageTags($dir, $file) { $extension_pos = strpos($file, '.'); // Find position of the last dot $filetitle = substr($file, 0, $extension_pos); // Filename without extension // Possible tag file $tags_file = $dir . '/' . $filetitle . '_tags.txt'; // Image path $image_path = $dir . '/' . $file; // 1. Check for a manually provided tags file if (file_exists($tags_file)) { return ' ' . trim(file_get_contents($tags_file)); } // 2. Check Exif metadata (XPKeywords field) $exifData = @exif_read_data($image_path, 'ANY_TAG'); if ($exifData !== false && isset($exifData['XPKeywords']) && !empty(trim($exifData['XPKeywords']))) { return ' ' . str_replace(";", ", ", trim($exifData['XPKeywords'])); // Exif sometimes uses semicolons } // 3. Check IPTC metadata (Keywords field) $size = getimagesize($image_path, $info); if (isset($info['APP13'])) { $iptc = iptcparse($info['APP13']); if (!empty($iptc['2#025'])) { // 2#025 is the IPTC keywords field return ' ' . implode(", ", array_map('trim', $iptc['2#025'])); // Convert array to comma-separated string } } // 4. Check XMP metadata (Xmp.Ir.weightedFlatSubject or dc:subject) $xmpData = file_get_contents($image_path); if (preg_match('/(.*?)<\/xmp:weightedFlatSubject>/s', $xmpData, $matches) || preg_match('/\s*(.*?)<\/rdf:Bag>\s*<\/dc:subject>/s', $xmpData, $matches)) { // Extract individual keywords from XMP RDF format preg_match_all('/(.*?)<\/rdf:li>/s', $matches[1], $xmpKeywords); if (!empty($xmpKeywords[1])) { return ' ' . implode(", ", array_map('trim', $xmpKeywords[1])); // Convert array to comma-separated string } } // 5. Fallback: No tags found return ''; } function getImageDateTime($image_path) { $exifData = @exif_read_data($image_path, 'IFD0'); if ($exifData !== false && isset($exifData['DateTime']) && !empty(trim($exifData['DateTime']))) { return trim($exifData['DateTime']); } return ''; // Return an empty string if no date is found } $use_separate_folders = false; $dir = '../resources/000_Fog/'; $file_display = array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'svg', 'webp'); if (!file_exists($dir)) { echo '

    Your directory of \'' . $dir . '\' could not be found.

    '; } else { $dir_contents = scandir($dir); asort($dir_contents); foreach ($dir_contents as $file) { // Ignore images that have '_thumb' in the name if (strpos($file, '_thumb') === false) { $tmp = explode('.', $file); $file_type = end($tmp); if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display)) { $filetitle = $file; $htmlId = generateHtmlIdFromFilename($file); $extension_pos = strpos($file, '.'); // Find position of the last dot $base_filename = substr($file, 0, $extension_pos); // Extract filename without extension $file_extension = substr($file, $extension_pos); // Extract file extension // Determine base directories $thumbnail_dir = ($use_separate_folders && !empty($thumbnail_dir)) ? $thumbnail_dir : $dir; $retina_dir = ($use_separate_folders && !empty($retina_dir)) ? $retina_dir : $dir; $caption_dir = ($use_separate_folders && !empty($caption_dir)) ? $caption_dir : $dir; $tags_dir = ($use_separate_folders && !empty($tags_dir)) ? $tags_dir : $dir; // Construct file paths $image_path = $dir . '/' . $file; if ($use_separate_folders) { // Use exact filename when separate folders are enabled $thumbnail_path = file_exists($thumbnail_dir . '/' . $file) ? $thumbnail_dir . '/' . $file : $image_path; $retina_image_path = file_exists($retina_dir . '/' . $file) ? $retina_dir . '/' . $file . ' 2x' : ''; $thumbnail_caption_file = $caption_dir . '/' . $base_filename . '.txt'; $lightbox_caption_file = $caption_dir . '/' . $base_filename . '.txt'; $tags_file = $tags_dir . '/' . $base_filename . '.txt'; } else { // Legacy behaviour (appending suffixes) $thumbnail = $base_filename . '_thumb' . $file_extension; $retina_image = $base_filename . '@2x' . $file_extension; $retina_image_alt = $base_filename . '_@2x' . $file_extension; // Alternative format $thumbnail_path = file_exists($thumbnail_dir . '/' . $thumbnail) ? $thumbnail_dir . '/' . $thumbnail : $image_path; // Check for both retina image formats if (file_exists($retina_dir . '/' . $retina_image)) { $retina_image_path = $retina_dir . '/' . $retina_image . ' 2x'; } elseif (file_exists($retina_dir . '/' . $retina_image_alt)) { $retina_image_path = $retina_dir . '/' . $retina_image_alt . ' 2x'; } else { $retina_image_path = ''; // No retina image found } $thumbnail_caption_file = $caption_dir . '/' . $base_filename . '_thumb.txt'; $lightbox_caption_file = $caption_dir . '/' . $base_filename . '_text.txt'; $tags_file = $tags_dir . '/' . $base_filename . '_tags.txt'; } // Get captions (ignoring missing files) $lightbox_content = getImageCaption($caption_dir, $file, 'both', '
    ', 'strong', 'span'); $thumbnail_content = getImageCaption($caption_dir, $file, 'title', '
    ', 'strong', 'span'); // Get image dimensions $dimensions = getimagesize($image_path); $thumb_dimensions = getimagesize($thumbnail_path); // Get image date/time $datetime = getImageDateTime($image_path); // Get tags $tags = getImageTags($tags_dir, $file); ?>
  • <?php echo $filetitle; ?>
  • Home
  • Weather and Sky
    • Lightning
    • Supercells
    • Tornadoes
    • Thunderstorms
    • Rainbows
    • Dust Devils
    • Floods
    • Wave Clouds
    • Sunrise/Sunset
    • Fog
  • Astrophotography
    • Moon
    • Deep Sky Objects
    • Comets
    • Aurora
    • Rockets
    • Eclipses
    • Telescopes
    • Miscellaneous Astro
  • Earth and Water
    • Canyons
    • Mountains
    • Rocks
    • Sand & Desert
    • Snow & Ice
    • Trees
    • Water
  • About the Photographer
  • Copyright
  • Photo Blog
  • Home
  • Weather and Sky
    • Lightning
    • Supercells
    • Tornadoes
    • Thunderstorms
    • Rainbows
    • Dust Devils
    • Floods
    • Wave Clouds
    • Sunrise/Sunset
    • Fog
  • Astrophotography
    • Moon
    • Deep Sky Objects
    • Comets
    • Aurora
    • Rockets
    • Eclipses
    • Telescopes
    • Miscellaneous Astro
  • Earth and Water
    • Canyons
    • Mountains
    • Rocks
    • Sand & Desert
    • Snow & Ice
    • Trees
    • Water
  • About the Photographer
  • Copyright
  • Photo Blog

  • Home
  • Weather and Sky
    • Lightning
    • Supercells
    • Tornadoes
    • Thunderstorms
    • Rainbows
    • Dust Devils
    • Floods
    • Wave Clouds
    • Sunrise/Sunset
    • Fog
  • Astrophotography
    • Moon
    • Deep Sky Objects
    • Comets
    • Aurora
    • Rockets
    • Eclipses
    • Telescopes
    • Miscellaneous Astro
  • Earth and Water
    • Canyons
    • Mountains
    • Rocks
    • Sand & Desert
    • Snow & Ice
    • Trees
    • Water
  • About the Photographer
  • Copyright
  • Photo Blog
Page last updated: 2025/06/17
© 2008-2025, David Blanchard Contact Me