WordPress Z-URL Preview Plugin

This plugin fetches an excerpt of an external website link. The exert contains the title, description and image.

V2.0.0 Added URL validation and XSS checks. If this breaks and valid URL’s please let me know via the WordPress support tab.

V1.5.2 Update: Added option to place the button in the “Media Button” row above the editor and changed the default for new install’s to use PHP’s HTML Dom instead of regex’s.

v1.5.0 Update: Rewrote the source parser to use PHP’s HTML Dom instead of regex’s. The default mode is the original regex’s, so you need to change the setting on the options page to enable this. The Dom mode always tries OpenGraph tags first, then fails back to regular meta tags, then to body content, i.e. img if no og:image, h1 if no og:title or title, 1st p if no og:description or meta description.

The options page allows the following to be set:

  • CSS to change the look and feel of the generated links.
  • The article source label. (Default “Source:”)
  • Control of new window opening. Options are ‘target=”_blank”‘, ‘target=”newwindow”‘, ‘rel=”external”‘ and opening in the same window. (Default ‘target=”_blank”‘)
  • Which TinyMCE button row the icon is added to (1,2 or 3).
  • Select regex parse mode (the original and default) or PHP’s HTML Dom mode.

The defaults are designed to suit most people.

Added the cacert.pem which CURL uses for https sites from http://curl.haxx.se/ca/cacert.pem (the home of CURL).

ToDo: Longer term, configurable options for sites without an image and selecting from multiple OG images.

This is my first attempt at a WordPress plugin. It’s not original, but an updated/enhanced version of Abhishek Saha’s URL Preview (https://wordpress.org/plugins/link-preview/).

You can see it working on recent articles here.

It’s been published at: https://wordpress.org/plugins/z-url-preview/

Related Posts