WordPress.org

Ready to get started?Download WordPress

Forums

Google XML Sitemap for Images
How to include galleries (8 posts)

  1. Steve Weblin
    Member
    Posted 3 years ago #

    How can I get Google XML Sitemap for Images plugin to include images that are in galleries. I am using NextGEN Gallery and would like to include those images on my sitemap.

    Your Google XML Sitemap for Images plugin works very well for single image in posts.

    http://wordpress.org/extend/plugins/google-image-sitemap/

  2. farbtoaster
    Member
    Posted 3 years ago #

    same problem, fixed it with same changes
    added this after foreach ($posts as $post) {

    //begin read ngg-pics,
          // post contents [gallery=?] ?, find gallery id / query in wp_ngg_pictures for galleryid,filename,description,alttext
          $content = '';
          $search_expr = '/gallery[ id ]?=[0-9]{0,3}\]/'; //could be better, regex isn't my favourite :-)
          preg_match($search_expr, $post->post_content, $found, PREG_OFFSET_CAPTURE);
          if (count($found) > '0') {
            $foundstring = implode(',',$found[0]);
            $number = '/(\d{1,3})/ '; //find id between 1 - 999
            preg_match($number, $foundstring, $found2, PREG_OFFSET_CAPTURE);
            $gallery = $found2[0][0];
            $_path = $wpdb->get_results ("SELECT path FROM {$wpdb->prefix}ngg_gallery
    							WHERE gid = '".$gallery."'"); // get gallery path
            $pics = $wpdb->get_results ("SELECT filename, description, alttext FROM {$wpdb->prefix}ngg_pictures
    							WHERE galleryid = '".$gallery."'"); //get fileinformation , should be made with one query using JOINS ???
    
    	      if (empty ($pics)) {
    		    //no pics? do nothing
            	} else { //pics found!
               $domain = get_bloginfo('url');
               $path = $_path[0];
               foreach ($pics as $pic) {
                $content .= '<img src="http://'.$domain.'/'. $path->path .'/'. $pic->filename.'"><br> ';
                }
              }
          }
          $post->post_content .= $content; //attach pics to the original post
    
          //end

    just a beginning, should search also for 'slideshow' and 'album' and all other nggallery shortcodes.

  3. jesuis
    Member
    Posted 3 years ago #

    i have the same problem... can you please tell me into which file i should insert the code?

  4. farbtoaster
    Member
    Posted 3 years ago #

    into the image_sitemap.php in the pluginfolder, only tested with the 1.0.1 version of the Google XML Sitemap for Images Plugin. Backup your files bevor!

  5. jesuis
    Member
    Posted 3 years ago #

    Thanks! Will try now....

  6. jesuis
    Member
    Posted 3 years ago #

    unfortunately no success - I am using version 1.0.1 but when added code to file the following warning appears above the header/logo on both my site & admin and the plugin just generated the same sitemap as before with no NextGEN galleries/images:

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /nfs/c06/h01/mnt/87305/domains/1am.co.nz/html/new/wp-content/plugins/google-image-sitemap/image-sitemap.php:298) in /nfs/c06/h01/mnt/87305/domains/1am.co.nz/html/new/wp-content/plugins/simple-twitter-connect/stc.php on line 33

    Any advise you may have would be much appreciated!

  7. farbtoaster
    Member
    Posted 3 years ago #

    Hm?

    headers already sent,
    please read this: http://www.phpbuilder.com/columns/anonymousjoe20080225.php3
    any blanks or other letters before the <? php in google-image-sitemap.php?
    other suggestion, your editor adds a BOM at the beginning.

  8. pushpinderbagga
    Member
    Posted 3 years ago #

    I created a multi-faceted plugin for the same - check it out here

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic