We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Extract URL Plus

Development and Programming

Daniel Walton's avatar
Daniel Walton
553 posts
18 years ago
Daniel Walton's avatar Daniel Walton

This plugin has been rebuilt. Please visit this thread for version 2.

Written solely for the purpose of getting filenames from custom fields populated by the upload form in publish, this plugin can be used to display file type, path, domain, description and many other properties of the URL it finds.

Example usage:

{exp:extract_url_plus show="% filename.% extension (% filesize)"}
    Some text, etc etc
    <a href="http://www.example.com/directory/myphoto.jpg">My file</a>
    Some more text?
{/exp:extract_url_plus}

REMOVE SPACE BETWEEN % AND VARIABLE NAME

This would return:

myphoto.jpg (4.87KB)

Available formatting variables to use within the “show” parameter are listed:

% fullurl - The full url (e.g., “http://www.example.com/directory/myphoto.jpg”) % protocol - (e.g., “http” / “https” / “ftp” / “ftps”) % subdomain - (e.g., “www”) % domain - (e.g., “example”) % tld - (e.g., “com”) % ip - If the hostname is an IP address, it is available in this variable. % path - (e.g., “directory/”) % filename - (e.g., “myphoto”) % extension - (e.g., “jpg”) % fullfilename - (e.g., “myphoto.jpg”) % hostname - If an IP address, this will be identical to the &#xip; variable, if not it might contain e.g., “www.ecample.com” % description - A brief description of the file, based on extension type. This can be customised in the plugin file if needed % filesize - Shows a readable filesize with unit denomination. To use this feature you may need to open the plugin file and edit the line that looks like: var $docpath = ‘/var/www/html/’;

If you are upgrading from an older version: The plugin will still honour the show parameter with a single variable, without the % sign.

Version 1.3.1

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
18 years ago
Mark Bowen's avatar Mark Bowen

Hi there,

Just came across this thread due to your other thread where people were asking for this functionality. Just to say thanks for the plugin but I was reading the documentation by going to the plugins section on my site and it said :

show=”xyz”

I was just wondering what this means? Do I have to place something specific in there for it to work such as the field name?

Thanks for any help with this and thanks for creating the plugin in the first place!

Best wishes,

Mark

       
Daniel Walton's avatar
Daniel Walton
553 posts
18 years ago
Daniel Walton's avatar Daniel Walton

Sorry im a bit lame when it comes to documentation! You put in that parameter what you want to show from the matched file, eg.. filename/extension/domain eg.. show=”extension”

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
18 years ago
Mark Bowen's avatar Mark Bowen

Hi there,

Don’t worry about the documentation side of things, do that myself a lot as well!! 😊

Thanks for the explanation. Terrific little plugin and will definitely find a use for it on upcoming projects.

Best wishes,

Mark

       
sigork's avatar
sigork
155 posts
18 years ago
sigork's avatar sigork

I tried this plugin (to understand what it can)

I wrote:

<b>filename: </b>

{exp:extract_url_plus show="filename"}
http://www.example.com/files/testing/test.zip
{/exp:extract_url_plus}

<br><br>

according to:

{exp:extract_url_plus show="xyz"} etc.. {/exp:extract_url_plus}

But I got:

filename: www.example.com

Not ‘test’.

       
Daniel Walton's avatar
Daniel Walton
553 posts
18 years ago
Daniel Walton's avatar Daniel Walton

I was wondering when “& # 47 ;” would rear it’s ugly head again.. anyway, problem fixed and i’ve added some more options for the show=”” parameter just for fun.

       
sigork's avatar
sigork
155 posts
18 years ago
sigork's avatar sigork

I uploaded your new 1.2 plugin, no other actions, I looked at it in the Plugin Manager only (intalled correctly, 1.2).

The same code (above), a new result:

domain: No URL Found path: No URL Found filename: No URL Found extension: No URL Found description: No URL Found
       
Daniel Walton's avatar
Daniel Walton
553 posts
18 years ago
Daniel Walton's avatar Daniel Walton

My bad, try it now.

       
sigork's avatar
sigork
155 posts
18 years ago
sigork's avatar sigork

yes, now absolutely correctly.

Maybe you find a couple of minutes to give 2 examples where it can be used (to activate my fantasy 😊 )

Thanks a lot.

       
Phoebe's avatar
Phoebe
58 posts
18 years ago
Phoebe's avatar Phoebe

Many thanks to the_butcher. I thought I was going to have to do a hack to achieve and what joy to find you had taken all the pain out of the task. 😊

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.

Can I ask…is there a way to make this extension do a ‘relative’ URL extraction, or a file name with extension?

For example:

{exp:extract_url_plus show="relative"}{img_file}{/exp:extract_url_plus}

Would output: /images/img.jpg rather than http://www.mysite.com/images/img.jpg. I guess just lopping off the host? This will make this plugin a little friendlier with phpthumb.

Also, what about the full file?

{exp:extract_url_plus show="fullfilename"}{img_file}{/exp:extract_url_plus}

Would output: img.jpg rather than img. I can work around this using the show=”extension” coupled with show=”filename”, but the code is a little ungainly.

       
Daniel Walton's avatar
Daniel Walton
553 posts
18 years ago
Daniel Walton's avatar Daniel Walton

I’ve thought to myself, previously, that it would be alot more functional to pass the plugin say a “display” parameter with a value such as “path filename” which would then show exactly that, path followed by filename. One day, i will do it!

For now though i will quickly bodge in those two other show values, Give me a second.

       
jasonjulien's avatar
jasonjulien
19 posts
18 years ago
jasonjulien's avatar jasonjulien

How do I have this show more than one parameter? Like so:

{exp:extract_url_plus show="filename|extension"}http://www.website.com/images/image.jpg{/exp:extract_url_plus}

which would give: image.jpg

I cannot seem to get multiple parameters to work. Is this possible? What’s the correct syntax?

       
Daniel Walton's avatar
Daniel Walton
553 posts
18 years ago
Daniel Walton's avatar Daniel Walton

I have updated, please re-download above.

       
jasonjulien's avatar
jasonjulien
19 posts
18 years ago
jasonjulien's avatar jasonjulien

the_butcher!

Three cheers to you! Now that is what I call service. Great work!!!!

       
1 2 3 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.