and like us on FB

Our online favicon generation tool (until a few days ago) included an API to return a favicon image that could be used with a PHP function to render the icon alongside any outgoing website link. The icon adds a stylistic element to links and provides a means of immediate brand recognition and assurance for popular websites.

While the service was free and provided a funky feature to users, it wasn’t without benefit on our end. Every time a request was made for an icon we would record various details as a means of measuring traffic to certain sites, and it gave us a unique means of measuring web trends. However, like all API-based services, it attracted its fair share of spammers and would at times result in dodgy online practitioners batch-requesting multiple hundreds of thousands of icons for their own use. It’s this ongoing abuse that has forced us to provide a time-expiry on the existing free icon API (the site will continue to manufacture site icons from uploaded images only). The API will be improved upon and ported over as a registered tool to this website in the next month. If you’re existing legitimate user, get in touch and we’ll provide you with a key.

Link-optimization is a hugely neglected part of SEO, and one of those areas that authors don’t necessarily consider when producing content. Our client-only (at this stage) plugin turns links into magnets, and it feeds search engines with everything they need to rank your content with authority.

For those that couldn’t be bothered with our new-and-improved service in the future, you can use a Google alternative to render a site icon alongside outgoing links. The function below makes use of Google’s icon API to return links that aren’t visibly different from our own current link functions.

Like all unregistered and ‘unofficial’ APIs provided by Google, there’s no guarantee of continued availability. However, the advantage of shortcode is that if (and when) Google closes its doors you can simply migrate over to another service.

Before we port the API over to this site, we’ll make details available here.

The Result

The shortcode of [link url="http://www.flight.org/" title="FLIGHT Link"]link in here[/link] returns the following: link in here FLIGHT Link (a link rendered with an icon image). For an external link External Link where you haven’t defined a title, we’ll return ‘External Link’. The icon itself will have a title element matching the destination site’s root domain.

If you’re linking internally, a post ID is always preferred to a qualified URL (the ID won’t be affected by permalink changes, domain changes, site reconfiguration etc). In such cases where you sensibly choose to use an ID rather than a URL, the shortcode of [link url="5156"]link in here[/link] will return link in here. Note that we’ve automatically retrieved and applied the title text. However, if you define your own title in your shortcode, we’ll use your custom text.

If you link to an unpublished post, we’ll return an empty link with the title of ‘Not Yet Published’. If the ID referenced in your shortcode is an image, we’ll return an image link with title and alt tags automatically populated (as long as you include the title tags when uploading images).

For those using our existing link shortcode function, the code below is a cut-and-paste replacement.

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

The shortcode requires that you include the function from “Get Root Domain from a URL with PHP” from this 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.

Shortcode Attributes

The following attributes are available.

url

The URL to link to; either a fully constructed URL or internal link/image ID.

title

The title tag. For internal links, it may be omitted and we’ll render the relevant page title or image title text. If provided in your shortcode it will be used.

size

The size of the Google icon. The icon is returned as a 16×16 image.

target

The target for external links. By default it will use _blank (new window).

follow

You don’t necessarily want to contribute towards the positive page-rank of linked websites. By default we’ll add rel="nofollow" tags to all outgoing links . To disable the tag, use follow=”1″.

internal

The internal URL root domain. Images won’t be rendered for internal links.

align

The vertical alignment of the Google icon image relative to text. We use -3 by default.

PHP Function

The purpose of the PHP function is to return just the Google icon.

Considerations

  • Our forthcoming code (dealing with our own API) includes additional link features such as automatically populating (and checking) and destination titles and automatic link truncation. It’s more of a complete link-SEO solution than just a simple tool.

The Favicon Series

  1. The Importance of a Website FaviconJuly 23, 2017
  2. Reference (Additional) Device Favicons in WordPressJuly 26, 2017
  3. Favicons with Outgoing Links in WordPress (or PHP) With Google’s Icon APIJuly 27, 2017

Download

Title: Favicons with Outgoing Links in WordPress (or PHP) With Google's Icon API
Description: Favicons with Outgoing Links in WordPress (or PHP) With Google's Icon API.
Download: Shortcode (V0.2) | PHP Code (V0.2) | Plugin Page

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