Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
Please, you'll need to be more specific about what you're trying to accomplish. Link module is simply a mechanism for users inserting links, I'm getting the feeling what you're requesting is out of the scope of link.module.
If needed, I'd suggest creating a module that implements hook_field_formatter_info() and adds a new formatter to links so that you can output them however you like. You can use the code in link.module as an example and create any kind of specialized output you like for links.
Well you can't do mime detection unless you have local access to the file. Which means you would have to download the file to just to do mime detection. And mime detection itself is not perfect even if we could count on mime extensions in linux which we can't.
My best suggestion for you is since what you are asking is about display then you can easily do some quick tests on the filename (mp3, etc) in your template and act accordingly.
You can easily do that yourself in your template or template preprocessor function or as quicksketch suggested a hook_field_formatter_info() function. There is nothing to with the extension with link so you have to add custom code anyway.
I have a need to scan a particular link CCK field I have and then be able to search for or filter by the MIME type of the remote resource (I guess I would grab the "Content-Type" header from the server's response).
Maybe that's what the request was about =)
I'm thinking this would be more appropriate in the Link Checker module, since it contacts the remote server to check links... it could then tag the node and/or field properly with the MIME Type from the response.
Comments
Comment #1
quicksketchI don't understand the request. Links do not have any "mime-type", they are just URLs.
Comment #2
chasz commentedbut it would be nice to detect mp3, jpg/gif/png, flv etc.....then we can play around with the links
Comment #3
quicksketchPlease, you'll need to be more specific about what you're trying to accomplish. Link module is simply a mechanism for users inserting links, I'm getting the feeling what you're requesting is out of the scope of link.module.
Comment #4
chasz commentedwhat i am asking for is a generalised field that can add a "field" format based on mimetype.....
ie. if a link is an image then a CSS class/html/php is added, if it's an mp3 then another class is added etc
in effect it s about 3 modules in one LOL :D
1. links
2. filter
3. replacement tag
Comment #5
quicksketchIf needed, I'd suggest creating a module that implements hook_field_formatter_info() and adds a new formatter to links so that you can output them however you like. You can use the code in link.module as an example and create any kind of specialized output you like for links.
Comment #6
chasz commentedi was hoping to get an ADMIN input field that takes care of each formatter :D
instead of manually in the themes
EDIT, which section of the links.module has the formatter?
EDIT2: i effect i am asking for a "bbcode" module for links
Comment #7
dragonwize commentedThe funcitonality is provided by the filefield module so I don't think link module needs to handle this.
Comment #8
chasz commentedfilefield only handle file ON your server with drupal, not external server
Comment #9
dragonwize commentedWell you can't do mime detection unless you have local access to the file. Which means you would have to download the file to just to do mime detection. And mime detection itself is not perfect even if we could count on mime extensions in linux which we can't.
My best suggestion for you is since what you are asking is about display then you can easily do some quick tests on the filename (mp3, etc) in your template and act accordingly.
Comment #10
chasz commentedwhat about detecting the file extension then?? doing regex test on the last 4 characters
Comment #11
dragonwize commentedYou can easily do that yourself in your template or template preprocessor function or as quicksketch suggested a hook_field_formatter_info() function. There is nothing to with the extension with link so you have to add custom code anyway.
Comment #12
quicksketchClosing, this is out of scope for link.module handling.
Comment #13
janusman commentedI have a need to scan a particular link CCK field I have and then be able to search for or filter by the MIME type of the remote resource (I guess I would grab the "Content-Type" header from the server's response).
Maybe that's what the request was about =)
I'm thinking this would be more appropriate in the Link Checker module, since it contacts the remote server to check links... it could then tag the node and/or field properly with the MIME Type from the response.