How to create image sitemap for nextgen gallery please anyone tell me
-
Hi Friends im using nextgen gallery , its so nice, but i dont know how to include nexgen gallery in sitemap, please anyone help me , is nextgen galley will suitable for me or i have to use wp default gallery
https://www.ads-software.com/extend/plugins/nextgen-gallery-optimizer/
-
is it possible to share your gtalk or skype id ..
Hi tollywoodandhra,
It appears your issue is now resolved, but if you do require further assistance with the WordPress SEO plugin, I would suggest contacting the plugin developer (https://www.ads-software.com/support/plugin/wordpress-seo) as they’d have a better understanding of the internal workings.
Cheers,
Mark.Hi Mark I tried this, but seems that my images still arent being indexed.
Here is my site map https://www.softfocus.co.za/photography/portfolio-sitemap.xml all my images are in this portfolio section. I updated the NG code as you said, cleared my WP super Cache and saved the site map in SEO setting again after that. Any advice you can give?
Thanks a lot
Hi Soft Focus,
I’ve been looking at your site, and it appears the missing images in your sitemap are all being displayed with jQuery via the Justified Image Grid plugin.
I would imagine the WordPress SEO plugin would not be able to detect these images, as they’re included dynamically instead of with regular HTML.
I hope this helps!
Cheers,
Mark.Hi Mark..
i took the screenshot of my webmasters sitemap and index status ….Please have a look and let me know your comment all the images are submitted Months Ago…
https://i39.tinypic.com/okdjbp.pngThanks mark, I havent tried your solution yet, but will in the future sometime.
I’m having the same problem with my gallery images not being indexed. I currently do not use a SEO plugin (tried Yoast’s but it somehow corrupted my site – probably my own customizing fault though) but just a plugin that creates a sitemap only. Would you have any hint for me how to get Google to recognize my pictures nevertheless?
Hi mark,
I read through quite many posts now and tried quite some things to get my pictures indexed, but still it looks like that seo yoast and nextgen seem to be conflicting. Could you maybe help me out? Any idea how I can get the images indexed? The site is captain-racket.de/Squash-blog.
Thanks a lot.
MichaelKello Mark Jeldi,
I did all the things you wrote above, but still get 0 images in my sitemaps. Can you please give me a hint what went wrong ?
Id appreciate your help.
https://www.zeglujznami.pl/ngg_tag-sitemap.xmle.g.
https://www.zeglujznami.pl/ngg_tag/mazury/btw. wordpress seo generated only 4 galleries, while there are at least 9
https://www.zeglujznami.pl/galeria-zeglarska/Thanks, anyone ?
Hello Everyone, hello Mark,
we have a music magazine at https://www.tribe-online.de and have problems finding our pictures back on Google. We use your great plugin to show off our concert shots.
It happens that we did a concert review on NAS, but when the author later checked google, only the article pic showed up, which was set without NextGen (nas site:https://www.tribe-online.de).
We use Google XML Sitemaps and wpSEO.
Thanks Patrik
Hi Everyone,
I use:
Wordpress 3.8
WordPress SEO 1.4.20
NextGEN Gallery 2.0.30I have a little trouble with my sitemap.
https://yana-butenko.com/blog-type-sitemap.xmlIt doesn’t include all images from NextGEN Gallery which added to post. For adding images in my posts I use “NextGEN Basic SinglePic” and “NextGEN Basic Thumbnails”. As a result my sitemap includes all singlepic and all preview singlepic, also it includes my post’s miniature.
But the sitemap not includes all images added through NextGEN Basic Thumbnails.If you’ll see my sitemap, you can see that the first string of the sitemap shows that post has 3 images. There are 6 images in this post really. Here is code:
<url> <loc>https://yana-butenko.com/ru/blogs/37-moskovskaya-mezhdunarodnaya-vyistavka-obrazovanie-i-karera-21-vek</loc> <lastmod>2013-10-06T19:10:39+00:00</lastmod> <changefreq>weekly</changefreq> <priority>0.6</priority> <image:image> <image:loc>https://yana-butenko.com/images/ngg_featured/20130228_00.jpg</image:loc> </image:image> <image:image> <image:loc>https://yana-butenko.com/nextgen-attach_to_post/preview/id--1548</image:loc> </image:image> <image:image> <image:loc>https://yana-butenko.com/images/gallery/blog20130228/20130228_01.jpg</image:loc> <image:title>blog20130228</image:title> <image:caption>20130228_01</image:caption> </image:image> </url>
Mark,
I tried to use your code for sitemap.php but then the sitemap includes preview singlepic and post’s miniature, but not includes fullscreen singlepic. Here is code:<url> <loc>https://yana-butenko.com/ru/blogs/37-moskovskaya-mezhdunarodnaya-vyistavka-obrazovanie-i-karera-21-vek</loc> <lastmod>2013-10-06T19:10:39+00:00</lastmod> <changefreq>weekly</changefreq> <priority>0.6</priority> <image:image> <image:loc>https://yana-butenko.com/images/ngg_featured/20130228_00.jpg</image:loc> </image:image> <image:image> <image:loc>https://yana-butenko.com/nextgen-attach_to_post/preview/id--1548</image:loc> </image:image> </url>
Help me, please. How can I add images which added through NextGEN Basic Thumbnails to my sitemap?
Thanks…
I am using Google sitemap for images. I have modified image-sitemap.php file to include nextgen 2.0 shortcodes. Please note at this point the code only respects “album_ids” “gallery_ids”, and “image_ids”. I have not coded for “exclusions” and “category” attributes etc. Please not I am coding in PHP after a decade (so there is room for improvement).
<?php /* Plugin Name: Google XML Sitemap for Images Plugin URI: https://www.labnol.org/internet/google-image-sitemap-for-wordpress/14125/ Description: This plugin will generate a XML Image Sitemap for your WordPress blog. Open the <a href="tools.php?page=image-sitemap-generate-page">settings page</a> to create your image sitemap. Author: Amit Agarwal Version: 2.1.3 Author URI: https://www.labnol.org/ */ add_action('admin_menu', 'image_sitemap_generate_page'); function image_sitemap_generate_page() { if(function_exists('add_submenu_page')) add_submenu_page('tools.php', __('Image Sitemap'), __('Image Sitemap'), 'manage_options', 'image-sitemap-generate-page', 'image_sitemap_generate'); } /* @author VJTD3 <https://www.VJTD3.com> */ function IsImageSitemapWritable($filename) { if(!is_writable($filename)) { if(!@chmod($filename, 0666)) { $pathtofilename = dirname($filename); if(!is_writable($pathtofilename)) { if(!@chmod($pathtoffilename, 0666)) { return false; } } } } return true; } function EscapeXMLEntities($xml) { return str_replace(array('&', '<', '>', '\'', '"'), array('&', '<', '>', ''', '"'), $xml); } function image_sitemap_generate () { if ($_POST ['submit']) { $st = image_sitemap_loop (); if (!$st) { echo '<br /><div class="error"><h2>Oops!</h2><p>The XML sitemap was generated successfully but the plugin was unable to save the xml to your WordPress root folder at <strong>' . $_SERVER["DOCUMENT_ROOT"] . '</strong>.</p><p>Please ensure that the folder has appropriate <a href="https://codex.www.ads-software.com/Changing_File_Permissions" target="_blank">write permissions</a>.</p><p> You can either use the chmod command in Unix or use your FTP Manager to change the permission of the folder to 0666 and then try generating the sitemap again.</p><p>If the issue remains unresolved, please post the error message in this <a target="_blank" href="https://www.ads-software.com/tags/google-image-sitemap?forum_id=10#postform">WordPress forum</a>.</p></div>'; exit(); } ?> <div class="wrap"> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0]; if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> <div style="width:800px; padding:10px 20px; background-color:#eee; font-size:.95em; font-family:Georgia;margin:20px"> <h2>XML Sitemap for Images</h2> <?php $sitemapurl = get_bloginfo('url') . "/sitemap-image.xml"; ?> <p>The <a target="_blank" href="<?php echo $sitemapurl; ?>">XML Sitemap</a> was generated successfully and you can <a target="_blank" href="https://www.google.com/webmasters/sitemaps/ping?sitemap=<?php echo $sitemapurl; ?>">ping Google</a> to inform them about your updated sitemap.</p> <p>This WordPress Plugin is written by <a href="https://www.labnol.org/about/">Amit Agarwal</a> of <a href="https://www.labnol.org/">Digital Inspiration</a>. For feedback or suggestions on improving this plugin, please send me an email at [email protected]</p> <p><a href="https://twitter.com/labnol" class="twitter-follow-button" data-show-count="false" data-lang="en">Follow @labnol</a> <iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fdigital.inspiration&send=false&layout=button_count&width=300&show_faces=false&action=recommend&colorscheme=light&font=arial&height=24&appId=197498283654348" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:20px;" allowTransparency="true"></iframe> </p> </div> <?php } else { ?> <div class="wrap"> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> <div style="width:800px; padding:10px 20px; background-color:#eee; font-size:.95em; font-family:Georgia;margin:20px"> <h2>XML Sitemap for Images</h2> <p>Sitemaps are a way to tell Google and other search engines about web pages, images and video content on your site that they may otherwise not discover. </p> <form id="options_form" method="post" action=""> <div class="submit"> <input type="submit" name="submit" id="sb_submit" value="Generate Image Sitemap" /> </div> </form> <p>Click the button above to generate a Image Sitemap for your website. Once you have created your Sitemap, you should submit it to Google using Webmaster Tools. </p> <p>You may also want to create separate <a href="https://www.ads-software.com/extend/plugins/xml-sitemaps-for-videos/">Video Sitemap</a> and <a href="https://www.ads-software.com/extend/plugins/google-mobile-sitemap/">Mobile Sitemap</a> for improving your site's visibility in Google.</p> <p>This WordPress Plugin is written by <a href="https://www.labnol.org/about/">Amit Agarwal</a> of <a href="https://www.labnol.org/">Digital Inspiration</a>. </p> </div> <?php } } function ks_get_ngg_album_ID_Matches($content) { return ks_getIDs_for_ngg_tag($content, 'album_ids'); } function ks_get_ngg_gallery_ID_Matches($content) { return ks_getIDs_for_ngg_tag($content, 'gallery_ids'); } function ks_getIDs_for_ngg_tag($content, $tag){ $search_expr = '/[tagname]=("|\')?[0-9]+(,[0-9]+)*("|\')?/'; $search_expr = str_replace("[tagname]", $tag, $search_expr); $search_delimited_number_exp = '/[0-9]+(,[0-9]+)*/'; if(preg_match_all($search_expr, $content, $matches, PREG_SET_ORDER)) { $allTagIDs=''; foreach($matches as $match) { preg_match($search_delimited_number_exp, $match[0], $del_numbers, PREG_OFFSET_CAPTURE); if ($del_numbers[0][0]!=''){ $allTagIDs .= $del_numbers[0][0] . ','; } } } return rtrim($allTagIDs, ','); } function ks_get_image_Tags_for_gallery_IDs($ids, $imgTemplateNode){ global $wpdb; // get gallery titles according to id's we got //$query_titles = "SELECT title, gid FROM wp_ngg_gallery WHERE gid IN('".$ids."')"; $FinalGalleryImageTags=''; $galleries = $wpdb->get_results ("SELECT gid, name, title, galdesc, path FROM {$wpdb->prefix}ngg_gallery WHERE gid IN (".$ids.")"); // get gallery path if (empty ($galleries)) { return ''; //no pics? do nothing } else { //pics found! $domain = get_bloginfo('url'); foreach ($galleries as $gallery) { $imgNodeGallery = str_replace('[img_caption]', $gallery->name.' : '. $gallery->galdesc.' [img_caption]', $imgTemplateNode); $imgBaseUrl = $domain.'/'. $gallery->path .'/'; $pics = $wpdb->get_results ("SELECT filename, description, alttext FROM {$wpdb->prefix}ngg_pictures WHERE galleryid = ".$gallery->gid); //get fileinformation , should be made with one query using JOINS ??? if (empty ($pics)) { return ''; } else { //pics found! foreach ($pics as $pic) { //return 'loompa-'.$imgNodeGallery.'</br>'; $currImageTag = str_replace('[img_caption]', $pic->alttext, $imgNodeGallery); $currImageTag = str_replace('[img_title]', $pic->description, $currImageTag); $currImageTag = str_replace('[img_url]', ($imgBaseUrl . $pic->filename), $currImageTag); $FinalGalleryImageTags .= $currImageTag; } } } } return $FinalGalleryImageTags; } function ks_add_ngg_tags($post_content){ global $wpdb; // ngg code - start $imgNode = "<image:image><image:loc>[img_url]</image:loc><image:title>[img_title]</image:title><image:caption>[img_caption]</image:caption><image:geo_location>[img_geo_location]</image:geo_location></image:image>"; $imgNode = str_replace('[img_geo_location]', 'New York City, New York, USA', $imgNode); $allImageTags=''; if (strpos($post_content, '[ngg_images') !== FALSE) { $album_ids = ks_get_ngg_album_ID_Matches($post_content); if ($album_ids!='') { // get the needed albums gallery id's $albumRows = $wpdb->get_results ("SELECT sortorder, albumdesc FROM {$wpdb->prefix}ngg_album WHERE id IN (".$album_ids.")"); if (empty ($albumRows)) { return ''; } else{ foreach ($albumRows as $albumRow) { $imgNodeAlbum = str_replace('[img_caption]', $albumRow->albumdesc.' : [img_caption]', $imgNode); $arrSortOrder = unserialize($albumRow->sortorder); $gallery_delim_ids = ''; for($i=0; $i < count($arrSortOrder); $i++){ if($i != (count($arrSortOrder)-1)){ $gallery_delim_ids .= (int)$arrSortOrder[$i].", "; }elseif($i == (count($arrSortOrder)-1)){ $gallery_delim_ids .= (int)$arrSortOrder[$i].""; } } //$allImageTags .= "******** album ***".$album_ids."****GALLERY*******". $gallery_delim_ids."<br/>".$imgNodeAlbum."<br/>"; $allImageTags .= ks_get_image_Tags_for_gallery_IDs($gallery_delim_ids, $imgNodeAlbum); //$content .= '<img src="https://'.$domain.'/'. $path->path .'/'. $pic->filename.'"><br> '; } } } else { $gallery_ids = ks_get_ngg_gallery_ID_Matches($post->post_content); $allImageTags .= ks_get_image_Tags_for_gallery_IDs($gallery_ids, $imgNode); } } // ngg code - end return $allImageTags; } function image_sitemap_loop () { global $wpdb; $posts = $wpdb->get_results ("SELECT id, post_parent, post_content, guid, post_type FROM $wpdb->posts wposts WHERE ((wposts.post_type = 'post') and (wposts.post_status='publish')) OR ((wposts.post_type = 'page') and (wposts.post_status='publish')) OR ((wposts.post_type = 'attachment') and (wposts.post_status='inherit')) and ((wposts.post_mime_type = 'image/jpg') or (wposts.post_mime_type = 'image/gif') or (wposts.post_mime_type = 'image/jpeg') or (wposts.post_mime_type = 'image/png')) "); if (empty ($posts)) { return false; } else { $xml = '<?xml version="1.0" encoding="UTF-8"?>'."\n"; $xml .= '<!-- Created by (https://www.ads-software.com/extend/plugins/google-image-sitemap/) -->'."\n"; $xml .= '<!-- Generated-on="'.date("F j, Y, g:i a").'" -->'."\n"; $xml .= '<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="https://www.google.com/schemas/sitemap-image/1.1">'."\n"; foreach($posts as $post) { $img=''; if($post->post_type == "attachment") { if($post->post_parent != 0) { $images[$post->post_parent][] = $post->guid; } } else if(preg_match_all("/[\'\"](http:\/\/.[^\'\"]+\.(?:jpe?g|png|gif))[\'\"]/ui", $post->post_content, $matches, PREG_SET_ORDER)) { foreach($matches as $match) { $images[$post->id][] = $match[1]; } } $img = ks_add_ngg_tags($post->post_content); if ($img !=''){ $xml .= "<url><loc>" . EscapeXMLEntities($post->guid) . "</loc>" . $img . "</url>"; } } foreach($images as $k => $v) { $img=''; $permalink = get_permalink($k); if ( ! empty ( $permalink ) ) { $img = "<image:image><image:loc>".implode("</image:loc></image:image><image:image><image:loc>", $v)."</image:loc></image:image>"; if ($img !=''){ $xml .= "<url><loc>" . EscapeXMLEntities($permalink) . "</loc>" . $img . "</url>"; } } } $xml .= "\n</urlset>"; } $image_sitemap_url = $_SERVER["DOCUMENT_ROOT"].'/sitemap-image.xml'; if(IsImageSitemapWritable($_SERVER["DOCUMENT_ROOT"]) || IsImageSitemapWritable($image_sitemap_url)) { if(file_put_contents($image_sitemap_url, $xml)) { return true; } } return false; } ?>
Plus I am working to make the same work for WP-SEO. I found “\plugins\nextgen-gallery\products\photocrati_nextgen\modules\ngglegacy\lib\sitemap.php” where I added code to take new shortcodes.
But it is not working. I am not sure how WP-SEO makes a call to this file. If someone can shed some light on that then I can come up with a solution.
A unit test with dummy post-content (in a variable) is working with the code I have. Just need to know who it gets triggered from WP-SEO. Would appreciate some help.I think I got WP-SEO working. It was a problem with NextGen Sitemap.php
Here is the updated code for “\plugins\nextgen-gallery\products\photocrati_nextgen\modules\ngglegacy\lib\sitemap.php”
Please note that this is for nextgen 2.0 shortcodes. Also at this point the code only respects “album_ids” “gallery_ids”, and “image_ids”. I have not coded for “exclusions” and “category” attributes etc.
<?php /** * Main PHP Class for XML Image Sitemaps * * @author Alex Rabe * @version 1.0 * @copyright Copyright 2011 * */ class nggSitemaps { var $images = array(); /** * nggSitemaps::__construct() * * @return */ function __construct() { add_filter('wpseo_sitemap_urlimages', array( &$this, 'add_wpseo_xml_sitemap_images'), 10, 2); } /** * Filter support for WordPress SEO by Yoast 0.4.0 or higher ( https://www.ads-software.com/extend/plugins/wordpress-seo/ ) * * @since Version 1.8.0 * @param array $images * @param int $post ID * @return array $image list of all founded images */ function add_wpseo_xml_sitemap_images( $images, $post_id ) { $this->images = $images; // first get the content of the post/page $p = get_post($post_id); // Backward check for older images $p->post_content = NextGEN_Shortcodes::convert_shortcode($p->post_content); // Don't process the images in the normal way remove_all_shortcodes(); // We cannot parse at this point a album, just galleries & single images C_NextGen_Shortcode_Manager::add( 'singlepic', array(&$this, 'add_images' ) ); C_NextGen_Shortcode_Manager::add( 'thumb', array(&$this, 'add_images' ) ); C_NextGen_Shortcode_Manager::add( 'nggallery', array(&$this, 'add_gallery') ); C_NextGen_Shortcode_Manager::add( 'imagebrowser', array(&$this, 'add_gallery' ) ); C_NextGen_Shortcode_Manager::add( 'slideshow', array(&$this, 'add_gallery' ) ); // KS-start: Code to accept new shortcode C_NextGen_Shortcode_Manager::add( 'ngg_images', array(&$this, 'add_ngg_images_tag' ) ); // KS-end: Code to accept new shortcode // Search now for shortcodes do_shortcode( $p->post_content ); return $this->images; } /** * Parse the gallery/imagebrowser/slideshow shortcode and return all images into an array * * @param string $atts * @return */ function add_gallery( $atts ) { global $wpdb; extract(shortcode_atts(array( 'id' => 0 ), $atts )); // backward compat for user which uses the name instead, still deprecated if( !is_numeric($id) ) $id = $wpdb->get_var( $wpdb->prepare ("SELECT gid FROM $wpdb->nggallery WHERE name = '%s' ", $id) ); $images = nggdb::get_gallery($id, 'pid', 'ASC', true, 1000); foreach ($images as $image) { $newimage = array(); $newimage['src'] = $newimage['sc'] = $image->imageURL; if ( !empty($image->title) ) $newimage['title'] = $image->title; if ( !empty($image->alttext) ) $newimage['alt'] = $image->alttext; $this->images[] = $newimage; } return ''; } /** * Parse the single image shortcode and return all images into an array * * @param array $atts * @return */ function add_images( $atts ) { extract(shortcode_atts(array( 'id' => 0 ), $atts )); // make an array out of the ids (for thumbs shortcode)) $pids = explode( ',', $id ); // Some error checks if ( count($pids) == 0 ) return; $images = nggdb::find_images_in_list( $pids ); foreach ($images as $image) { $newimage = array(); $newimage['src'] = $newimage['sc'] = $image->imageURL; if ( !empty($image->title) ) $newimage['title'] = $image->title; if ( !empty($image->alttext) ) $newimage['alt'] = $image->alttext; $this->images[] = $newimage; } return ''; } // KS-start: Code to accept new shortcode function add_ngg_images_tag( $atts ) { global $wpdb; extract(shortcode_atts(array('image_ids' => 0, 'album_ids' => 1, 'gallery_ids' => 2), $atts )); if ($image_ids!='' and $image_ids!=0){ // make an array out of the ids (for thumbs shortcode)) $pids = explode( ',', $image_ids ); // Some error checks if ( count($pids) == 0 ) return; $images = nggdb::find_images_in_list( $pids ); nggSitemaps::add_to_global_images_array($images); return ''; } if ($album_ids!='' and $album_ids!=0) $gallery_ids = nggSitemaps::get_galleryIDs_from_albumID($album_ids); if ($gallery_ids=='' or $gallery_ids==0) return ''; $gallery_id_arr = explode(',',$gallery_ids); foreach ($gallery_id_arr as $id) { $images = nggdb::get_gallery($id, 'pid', 'ASC', true, 1000); nggSitemaps::add_to_global_images_array($images); } return ''; } function get_galleryIDs_from_albumID($album_ids){ global $wpdb; $albumRows = $wpdb->get_results ("SELECT sortorder FROM {$wpdb->prefix}ngg_album WHERE id IN (".$album_ids.")"); $gallery_delim_ids = ''; if (empty ($albumRows)) { return ''; } else{ foreach ($albumRows as $albumRow) { $arrSortOrder = unserialize($albumRow->sortorder); for($i=0; $i < count($arrSortOrder); $i++){ if($i != (count($arrSortOrder)-1)){ $gallery_delim_ids .= (int)$arrSortOrder[$i].", "; }elseif($i == (count($arrSortOrder)-1)){ $gallery_delim_ids .= (int)$arrSortOrder[$i].""; } } } } return $gallery_delim_ids; } function add_to_global_images_array($images){ foreach ($images as $image) { $newimage = array(); $newimage['src'] = $newimage['sc'] = $image->imageURL; if ( !empty($image->title) ) $newimage['title'] = $image->title; if ( !empty($image->alttext) ) $newimage['alt'] = $image->alttext; $this->images[] = $newimage; } } // KS-end: Code to accept new shortcode } $nggSitemaps = new nggSitemaps();
- The topic ‘How to create image sitemap for nextgen gallery please anyone tell me’ is closed to new replies.