• I am trying to use this plugin to build a very custom store locator on a site. So far everything is going well because the plugin is extremely customizable. But 1 thing I am having an issue with is thumbnail images. My client has over 4000 locations that could be found, so using the WP featured image is not really a ideal solution. However most of the businesses that we are putting into the site have a Google Places page set up with images. I would love to see the ability to pull that image for the thumbnail. Is this something that I could extend your current code with filters, or is this something that the core of the plugin would need to be altered?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    I never used the Google Places API myself. Can you request images based on the coordinates / street address? If this it he case, then yes, you can make it load the image and use it in the search results.

    Let me know if the above is the case, then I will explain how to make it work.

    Thread Starter Rob_Huska

    (@rob_huska)

    Yes, you can. But you need to get the place_id first, which you can get from the address/coordinates. Here is how I was getting the place_id:

    
    var request = {
    		'address': response[index].address + ' ' + response[index].city + ', ' + response[index].state + ' ' + response[index].zip
    	};
    
    geocoder.geocode( request, function( response, status ) {
    	if ( status == google.maps.GeocoderStatus.OK ) {
    		console.log(response[0].place_id);
    	}
    });
    

    I did this in your wpsl-gmap.js file inside the $.each loop while you are gathering the locations. Around line @1207. Again I am hoping to not modify your code, but add my own js in my own files if at all possible.

    • This reply was modified 8 years, 9 months ago by Rob_Huska.
    Plugin Author Tijmen Smit

    (@tijmensmit)

    Is there no way to make a HTTP request through PHP?

    If so, then you can use the wpsl_store_meta filter.

    You access the collected location data ( address / coordinates etc ), and then use that to make a request to the Places API to get place images.

    An alternative solution is to use ajaxComplete. Load a custom JS file through the functions.php in your theme folder, in the file listen for ajaxComplete and then run through the results, grab the address details for each results, make a request to the places API and update the search results.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Pulling Google Places image for thumbnail’ is closed to new replies.