Adds icons automatically to any uploads and/or file links inserted into your blog posts.
MimeTypes Link Icons is a plugin that looks for links to files and uploads in your blogs posts and adds a nice icon next to it. Optionally add the file’s file size next to the link.
Important note on v3.0 and up: This version partially breaks backwards compatibility: the plugin now requires PHP5.1+ and WP 3.5+. Please have a look at the changelog for more information about the changes.
The icons are configurable. You can choose to display a PNG with transparent background or GIF with white matte, display the icon to the left or the right of the link and choose the icon size.
Each icon is available in the following sizes:
Please help make this plugin available in more languages by translating it. The translation files are included in the download. See the FAQ for more info.
Since version 3.0, the plugin now requires PHP5.2+ and WP 3.5+.
The PHP filter extension needs to be enabled as well.
If you need support for this plugin or even want a completely different plugin programmed: hire Toby or Juliette!
First thing to check is whether you are using the latest version, if not, please upgrade and check again.
If you are getting a blank screen when saving the settings, please check that the PHP filter extension is enabled – it is enabled by default in a normal PHP installation, though some disreputable webhosting companies seem to disable it. If that’s the case, contact your webhost to get them to turn it on.
You can check your server php configuration using the code snippet below:
<php
phpinfo();
If the error persists, please report any errors you are getting in the WP forum or on GitHub. Error reporting is much appreciated as it will improve the plugin for everyone!
We’ll need at least the following information:
Sometimes we may need information on the settings you are using. If you have WP_DEBUG
set to true
, you will see a list of the plugin settings at the bottom of the MimeType Link Icons settings page.
On rare occasions, like with problems with the filesize functions, we may need even more information. We will then ask you to turn on a plugin-specific debugging option.
To do so, please add the following to your (child-)theme’s functions.php file:
$GLOBALS['mimetypes_link_icons']->debug = true;
You may want to wrap this snippet in an if( WP_DEBUG === true ) {}
and you can remove it once you’ve send us the output.
Alternatively, you can (temporarily) change the variable in the plugin file, search for the following code snippet and change false
to true
:
/** * @var bool Debug setting to enable extra debugging for the plugin */ var $debug = false;
mimetypes_link_icons
folder to your /wp-content/plugins/
directory. Alternately, you can install directly from the Plugin directory within your WordPress Install.No. It searches your post for any links containing the file extensions you have activated. This will be triggered by any link within the normal content area.
No worries 😉 Just enable the classnames setting on the settings page and add one or more classnames.
The way this works is as follows:
The plugin will look for the classname in your document and will remove the Mimetypes link icons (and file sizes) from all links wrapped within that class.
Examples:
Please note: Classnames may differ depending on your theme, so look at the html source of the relevant pages to determine which classname(s) to exclude.
You can 😉
First of all, you can change the rounding precision for the file size on the settings screen.
Secondly, there’s an output filter available for your use which will receive the formatted file size string which will look something along the lines of (123.4 kB)
.
To use the filter add a snippet like the following to your (child-)theme’s functions.php file:
function my_function( $formatted_file_size ) { // do your thing return $formatted_file_size; } add_filter( 'mtli_filesize', 'my_function' );
Please note: be aware that the file size string will be added to the page via CSS, so the output of your function should be usable in a CSS string!
Yup! Just uncheck the ‘cache file sizes’ checkbox, save your settings and then check the checkbox again. The file size cache has now been cleared.
Yes you can.
If you generate the output yourself in a template file, change:
echo $my_content;
to
echo mimetypes_to_icons( $my_content );
or even better, if the content you want to change supplies you with an output filter – add the following to your (child-)theme’s functions.php file:
add_filter( ‘name_of_output_filter’, ‘mimetypes_to_icons’, 15 );
for instance:
add_filter( ‘widget_text’, ‘mimetypes_to_icons’, 15 );
Please note: the icons generated for that specific content area, will be generated in non-async mode. All other settings will be respected.
You can 😉
There’s an output filter available for the attachment link classes.
Mind: the $classnames_string
variables holds all the classes – not just the MTLI classes – which the attachment link, i.e. the <a>
tag, has.
To use the filter add a snippet like the following to your (child-)theme’s functions.php file:
function my_classnameFunction( $classnames_string ) { // do your thing return $classnames_string; } add_filter( 'mtli_classnames', 'my_classnameFunction' );
This is outside of the scope of this plugin, but you should probably read this explanation (includes code sample) on how to add more file types to the WordPress allowed list in an upgrade-friendly manner.
However, if you do add extra file types to your blog and these file types would not (yet) be included in this plugin, you can add the mimetype extensions to the list this plugin uses, by using the filter hook we provided for this purpose.
To use the filter add a snippet like the following to your (child-)theme’s functions.php file:
function change_mimetypes( $current_mimetypes ) { // do your thing to the array // // ie $current_mimetypes[] = 'mp6'; // // or $current_mimetypes = array('mp4','pdf','zzz'); - don't forget to add your own css to your stylesheet in the format .mtli_[extension_without_dots] {background-image:url('/path/to/your/icon')} return $current_mimetypes; } add_filter( 'mtli_active_mimetypes', 'change_mimetypes' );
You can temporarily suspend this plugin by using the pause_mtli() and unpause_mtli() functions.
Add the following code to your plugin where you want to suspend the plugin:
if( function_exists( 'pause_mtli' ) ) { pause_mtli(); } // Your code if( function_exists( 'unpause_mtli' ) ) { unpause_mtli(); }
Please do advise your users about your use of these functions as we’re not looking to get complaints from users about this plugin not working 😉
The plugin is fully translation ready and translations are much appreciated!
Use the /languages/mimetypes-link-icons.pot
file which is included in the download to create a new .po file for your language.
To get your translation included in the next release of this plugin:
If you need more information, read this article on how to translate using a .po file.
rel
for other uses conflicted with mtli. Swapped for data-mtli
And further:
* Fully leveraged the Options API
* Upped the minimum WP level to fully take advantage of new functions and APIs
* Tested up to WP 3.8-beta
* Code style validated against WordPress standards
* Added API documentation
* One time only force update of internal domains option
* Improved charset support for settings page
* Small improvements in validation
* Removed auto-deactivation if run on old versions (was buggy)
* Various small code tweaks
[New file extensions] And some more: .tiff, .ico, .ttf, .qt, .air, .msi, .sql, .flv
[New feature] Ability to disable this plugin for more than one classname
[New feature] Ability to have mimetype icons for content outside of the loop See the FAQ for info on how to use this.
[Usability] Added ‘check all’/’uncheck all’ togglers for the file types to the settings page
[Usability] Added clean uninstall routine
[Compatibility] Added pause_mtli() and unpause_mtli() functions for use by other plugins in case of (page specific) conflicts. See the FAQ for info on how to use this.
[Bug fix] Images didn’t display if wp-content and/or the plugins directory was in a non-standard location.
[Bug fix] File size retrieval should now also work for (most) relative paths
[Localization] Added .pot file to enable translations of this plugin
[Code improvements] Complete rewrite in OO style including implementation of the Settings API
[Code improvements] Greatly improved input validation for the options page
[Misc] Added GPL license information