Drupal - Ampersand in ImageField

Kevin's picture

[b]Q:[/b] I have a [url=http://drupal.org/project/cck]CCK[/url] [url=http://drupal.org/project/imagefield]ImageField[/url] for uploading pictures to my content type. It all works fine until a user tries to upload an image with an ampersand (&) or another funny character in the filename - The thumbnail will display in the node edit screen but otherwise I can't see the image in the node display or in views etc. What can I do? I can't force my users to upload images without ampersands!!

[b]A:[/b] You can use the [url=http://drupal.org/project/transliteration]Transliteration[/url] module to sanatise upload filenames including ImageField filenames. It will change the filename when the file is uploaded, replacing things like spaces and ampersands with underscores.

We have hit this problem before, especially on one of our Cork client's websites. You can't always control the filenames that people use when uploading images to your website and so it is no good when an image uploaded by one of your visitors won't display because of an ampersand in the filename. This is the kind of thing that you would expect drupal to handle out of the box...

Well the good news is that the [url=http://drupal.org/project/transliteration]Transliteration[/url] can help. Just download it, install and enable it. Once installed it will sanitise upload filenames when the files is uploaded.

It adds some settings to the 'Admin / File System page' (admin/settings/file-system), but you probably won't have to change them - just install & go!

The settings are:

Checkbox - [b]Transliterate file names[/b] during upload, this switches on the automatic sanitisation functionality so you will probably want this checked, default values is checked.

Checkbox - [b]Lowercase transliterated file names[/b] this just puts filenames to lowercase to help with case-insensitive file systems. This is not really relevant to the ampersand problem but it does no harm, default values is checked.

Once installed the module won't fix any images that have already been uploaded, but any images uplaoded after this should be ok.

Share this post: 

Recent Work

Some of Ireland's biggest brands use Pride Design to Design, Build, Manage, Market and Maintain their websites.

Website design for St.Patricks Credit Union in Dublin, Including Loan Calculators.

Website design and development for a step by step wedding and other stationary ordering website f

New website designed and developed for Cork's newest café, which is based in Merchants Quay in Co

New Website design for Pain Relief clinic based in Cork City.

Website for a busy Dublin city centre pub.

We redrafted the Ballymaloe house website to modernise the look and feel of the site and to also

We revamped the website for the Ballymaloe Cookery School.

We revamped the Cully & Sully website onto Drupal.

Rachel Allen was brought up in Dublin and left home at eighteen to study at the world-famous Ball

Clóna Dairy Products are a Dairy Company based in Clonakilty, Co. Cork, since 1919.

Project Arts Centre is Ireland’s leading centre for the presentation and development of c