function lg_get_image_id($folder, $img) { $images_data = get_image_caption($folder); for ($i = 0; $i < count($images_data); $i++) { if ($images_data[$i][image] == $img) { $id = $images_data[$i][id]; } } return $id; }
the_post(); the_content(); echo '</div>'; echo '<div class="col-xs-12 col-sm-6 col-md-6">'; $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'feature-box-thumb'); ?> <figure> <img src="<?php echo make_path_relative($image_url[0]); ?> " class="img-responsive" alt="<?php echo $post->post_title; ?> "> <?php get_image_caption(); ?> </figure> <?php echo '</div>'; } } } elseif (empty($feat_box) && the_post_thumbnail() == null) { echo $content_with_feat_box; if (have_posts()) { while (have_posts()) { the_post(); the_content(); } } echo '</div>';
/** * This function removes or rebuilds HTML tags (depending the need). * If $verse is "true" (default) HTML tags are restored * If $verse is "false" HTML tags are converted from "<" and ">" to "[" and "]" * It returns false if it fail gather image captions * NOTE: This function returns a string */ function clean_image_caption($img, $dir, $verse = true) { if (!($images = get_image_caption($dir))) { return false; } for ($i = 0; $i < count($images); $i++) { if ($images[$i][image] == $img) { $xml_caption = $images[$i][caption]; } } if ($verse) { $xml_caption = str_replace('"', '\'', $xml_caption); $xml_caption = str_replace('[', '<', $xml_caption); $xml_caption = str_replace(']', '>', $xml_caption); } else { $xml_caption = str_replace('"', '\'', $xml_caption); $xml_caption = str_replace('<', '[', $xml_caption); $xml_caption = str_replace('>', ']', $xml_caption); } return utf8_decode($xml_caption); }
function al_generate_xml($capdir) { global $gallery_root; if (is_writable($gallery_root . $capdir)) { // Gather the image's informations and ID number $imgfiles = get_imgfiles($capdir); $images_data = get_image_caption($capdir); // Check if $capdir ends with the "/" and providing one if not if (substr($capdir, strlen($capdir) - 1, strlen($capdir)) != "/") { $capdir .= "/"; } $handle = fopen($gallery_root . $capdir . 'captions.xml', 'wb'); fwrite($handle, "<?xml version='1.0' encoding='" . get_option('blog_charset') . "'?>\n"); fwrite($handle, "<data>\n"); // Folder caption; TODO valute htmlentities() $folder_caption = utf8_encode(str_replace('\\', '', $_POST['folder_caption'])); fwrite($handle, "\t<folder>" . $folder_caption . "</folder>\n"); // Folder access level $folder_access = $_POST['folder_minimum_level']; fwrite($handle, "\t<level>" . $folder_access . "</level>\n"); if (isset($imgfiles)) { foreach ($imgfiles as $img) { // prepare the strings to be written $form_value = str_replace('.', '_', $img); $form_value = str_replace(' ', '_', $form_value); $dirty_caption = utf8_encode($_POST[$form_value]); $clean_caption = str_replace('\\', '', $dirty_caption); // write strings fwrite($handle, "\t<photo id='" . $img . "'>\n"); fwrite($handle, "\t\t<caption>" . $clean_caption . "</caption>\n"); for ($i = 0; $i < count($images_data); $i++) { if ($images_data[$i][image] == $img) { $image_number = $images_data[$i][id]; } } // If is not setted update the counter and... if (strlen($image_number) == 0) { add_option('lg_image_indexing', '0', 'Lazyest Gallery images index to retrive comments'); $image_number = get_option('lg_image_indexing'); $counter = $image_number + 1; update_option('lg_image_indexing', $counter); } // ...provide one fwrite($handle, "\t\t<image>" . $image_number . "</image>\n"); fwrite($handle, "\t</photo>\n"); } } fwrite($handle, "</data>"); fclose($handle); @chmod($gallery_root . $capdir . 'captions.xml', 0666); } else { return lg_cannot_rw($capdir); } }