Friday, October 28, 2016

Downloaded buttons now named after the button text

When downloading a generated button image to your computer, its filename will now be based on the button text content, instead of always being the generic button.(png|jpg|gif|ico).

For instance, if the text is “Learn more”, the button filename will be button_learn-more.png. If the text is “Redeem your promotion code!”, the filename will be button_redeem-your-promotion-code.png.

This is especially useful when creating a batch of buttons that only differ in their text. With this new feature, the downloaded images have meaningful filenames that are easily differentiated.

Caveats


There are some characters that are unsafe or inconvenient to use in a filename, especially if you intend to share the file (via email, etc.) with people using different operating systems.

So some transformations are applied to the button text to make it suitable as a filename. We chose to err on the side of safety at the cost of, sometimes, quite heavily modifying the text.

Spaces are replaced by hyphens, and things likes punctuation marks get removed. Greek & cyrillic characters get transliterated to latin ones, and diacritics on latin characters are scrapped.

As a result, the filename will always only contain (a subset of the) ASCII characters. This also has advantages if the buttons are to be put on the web; their URLs won’t need any escaping.

The name is also all lowercase, mainly because some systems (notably, macOS) are case-insensitive.

Browser compatibility


Sadly this feature is not effective on all browsers, notably not in Internet Explorer and Safari.
It should however work in Safari 11, which is yet to be released at the time of this writing. As for Internet Explorer, its development has stopped and it has been replaced by a new browser, Microsoft Edge, since Windows 10. (This feature is effective on Edge.)