and like us on FB

We originally wrote this code in 2010 with the expectation that WordPress would cease proving their screenshot API to the public. In the typical open spirit of WordPress, however, WP has stated that usage is fine as long as there’s no expectation it’ll last forever (we’re sure that WP never intended for their service to be used indiscriminately by the online world). The feature was originally used to display screenshots of Commercial Themes . It’s since made its way into your administration dashboard to associate URLs with website snapshots.

The following functions make use of the WordPress snapshot API and renders a screenshot on any post or page.

The Result

The shortcode of [snap url="http://www.flight.org/" alt="Flight" width="530" height="280"] will return the following image:

Flight

If the image isn’t immediately available you’ll see a preview image. The API appears to return an image with a maximum resolution of 1280 x 960 pixels.

The Code

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

You can define the website URL (url), alt text (alt), width (width), height (height), and image alignment (align) by way of shortcode attributes.

The first time you call the website it will take some time to render (it seems to cache on WordPress for an unknown period after that). I suggest you preview the post first and let the screenshot render before you publish your post to the world.

PHP Function

Using the function outside of WordPress seems a little unethical and I wouldn’t recommend it. However, for the sake of completeness, the following PHP function will return a snapshot.

Considerations

  • Given the nature of the source, respect the limits of your use. Don’t expect any longevity from the service.
  • We have our own screenshot tool at Screenshotz . We’ll soon be migrating all the features of that site into BeliefMedia and retiring the old platform.

Download

Title: Website Snapshots with WordPress Shortcode
Description: Shortcode makes use of the WordPress snapshot API and renders a website screenshot of any page or post.
Download: Shortcode (V0.2) | WP Plugin (V0.2) | PHP Code (V0.2)

Shortt URL for this post: http://shor.tt/1qjE