A5hleyRich / delightful-downloads

A super-awesome downloads manager for WordPress.
https://delightfuldownloads.com
26 stars 27 forks source link

Change %ext% output to lowercase or add new %extlc% wildcard #163

Open vtamm opened 8 years ago

vtamm commented 8 years ago

I wanted to use the %ext% wildcard to include the document icons in my custom list like so:

<img src="'.get_site_url().'/wp-content/plugins/delightful-downloads/assets/icons/%ext%.png">

However this doesn't work since the extension is converted to uppercase when replacing %ext% on this line.

There's currently no way of outputting the file extension in lowercase. Since the output of %ext% can very easily be converted to uppercase using CSS, I would like to suggest either getting rid of strtoupper() on the referenced line above, or that a new %extlc% wildcard is added:

// file extension lowercase
if ( strpos( $string, '%extlc%' ) !== false ) {
    $value = dedo_get_file_ext( get_post_meta( $id, '_dedo_file_url', true ) );
    $string = str_replace( '%extlc%', $value, $string );
}

Whichever way you prefer, just let me know if you want me to send a PR.