Closed (won't fix)
Project:
FileField
Version:
6.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
21 Oct 2009 at 11:09 UTC
Updated:
28 Jan 2010 at 18:29 UTC
On a certain node type, I would like my users to be able to upload anything, be it an image or a file. Can I use filefield and have the module recognize that the uploaded file is an image and then magically transform into imagefield (software like vbulletin already do this)? This is way better than having 2 fields just sitting there.
Thanks.
Comments
Comment #1
quicksketchYou can't magically make a FileField and ImageField, CCK will always recognize a widget type as whatever it was original created as. However you can accomplish what you're asking simply by theming the FileField Widget to show an image if an image is uploaded. You could do similar things to make audio files have a player or video files show a thumbnail.
To do this, just override the theme_filefield_widget_preview() function, which provides the preview next to the uploaded file. Take the function out of filefield_widget.inc, copy it into your theme's template.php, and rename it to [yourtheme]_filefield_widget_preview(). Then do any changes you want, and clear your Drupal caches at admin/settings/performance.
Comment #2
Flying Drupalist commentedI'm thinking, enable both widgets, but when uploading let js check for file extension, and if is jpg/gif/png use imagefield otherwise use filefield?
Otherwise you would lose the features of imagefield, which are too numerous to list.
Comment #3
quicksketchThere is no easy way to accomplish this. It sounds like a difficult thing to implement that would be very sensitive to changes on the site (such as theming the node form, or positions of the FileField and ImageField). ImageField is purely built on top of FileField, so between the two of them they should have very similar functionality.
Comment #4
philbar commentedI would love to see this too.
I've long thought about having FileField detect the image types and display them with the ImageField widget.
Comment #5
quicksketchThis will not be added. FileField is essentially discontinued since it has been integrated into Drupal core.
Comment #6
aaron commentedlook at FileField Styles, which does this (and works in d7 as well).