My Mountain Trail

Random Photos, Stories, and Thoughts from Our Life on Mt. Tamalpais

Nearby Photos Widget for WordPress

Version 0.9

Download the Widget

An example of this Worpress widget is shown at left. The widget finds geotagged Flickr photos taken near a given location and displays them. The most “interesting” photos, as determined by Flickr, are displayed first. The initial location is set by you in the widget controls, and then your blog readers can click on a link to load photographs taken near their actual location. You can see the widget in action on my blog home page sidebar.

The reader’s location is determined using the database of wi-fi hotspots. The widget controls are managed from the Widget control panel using the form shown below:

  • Widget Title. You can customize the widget title.
  • Starting location. The starting location can be set using your desired longitude and latitude. This information is used to find pictures for the widget when the page loads. You can set any location you want, but keep in mind that Flickr may not have geotagged pictures near your selected location.
  • Radius. Set the distance from the desired longitude and latitude that you want to search for pictures. Flickr allows you to use up to a 32 kilometer radius. If you enter more than 32km, Flickr will default to 32km. If you do not specify a radius, the Flickr default value is 5km.
  • Number of Photos. This is the number of photos you want the widget to load on your page. Depending on the format of the widget area in your page, you may want to adjust this number. The maximum number (as limited by the Flickr database) is 500, however Flickr limits the number in their API Key agreement to 30. In addition, there may not be as many pictures available in the specified area as you set in this box. When this happens, the widget will load the pictures that are available. If there are no pictures available, the user will get an alert message saying that this.
  • Search Time-frame. You can specify the number of days you want to include in your search in this box. The time of search starts with the time the page loads. So, if you enter 10 in this box, you will search for photographs taken with the specified area over the last ten days. If you do not set a limit on the search time, Flickr defaults to a 12-hour search period. This keeps their database load from exploding, but it may not give you very many pictures to look at.
  • Flickr API Key. You will need a Flickr API key to access their database. These keys are very easy to get and they are free. It will take you five minutes. You can get your key here. It may take Flickr a day or two to get back to you with the details.
  • Loki API Key. You also need a Loki API key. This is another 5-minute, free effort. Go here for your new key. Loki’s response time was just a few minutes for me.

In the event that your readers do not have wireless on their computer, or are not in an area with wireless coverage, the location program will use the ISP location. This is generally not as accurate as using the wireless location data, but it does provide some pictures taken near the ISP, which is often near the user.