How to increase custom fields length to be more than 255 characters


Joined: 2006-02-15
Posts: 6
Posted: Sat, 2006-06-17 14:01


Just want to share how to overcome the limitation of max. 255 characters in custom fields.

Two changes are needed:

1. DB change

If using phpMyAdmin
a) Go to table g2_CustomFieldMap
b) Mark field g_value
c) Select change pen
d) Change type to be TEXT instead of VARCHAR
e) Save the change
In my case already entered values in g_value where kept in the DB.

2. Change
a) Open file /gallery2/modules/customfield/classes/
b) Change 'value'=>array('type'=>STORAGE_TYPE_STRING to 'value'=>array('type'=>STORAGE_TYPE_TEXT
c) Be aware that this file was automatically created from Maps.xml

3. Clear DB cache
a) In Gallery go to Site-Administration and Maintenaince
b) Clear the data base buffer (needed in case of manual DB update like under 1. above)

Now, more than 255 characters should be available for the value in all custom fields.

Have fun,

Gallery-Version = 2.1.1 Kern
PHP-Version = 4.4.0 apache2handler
Webserver = Apache/2.0.54 (Linux/SUSE)
Database = mysql 4.1.13-log, lock.system=flock
Activated toolkits = Exif, Thumbnail, Gd, Getid3
Operating system = Linux sinatra 2.6.13-15-smp #1 SMP Tue Sep 13 14:56:15 UTC 2005 x86_64
Browser = Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.13) Gecko/20060411


Joined: 2007-07-22
Posts: 21
Posted: Sun, 2007-07-29 06:58

Thankyou this is just what I needed.


Joined: 2008-02-04
Posts: 4
Posted: Thu, 2008-02-07 09:37

Thanks so much for this, you wont belive how much hassle this has saved me!


Joined: 2009-02-25
Posts: 18
Posted: Thu, 2009-02-26 11:45

Im havign a problem migrating keywords ... so I am reverting thi. anyione else have that problem running this mod?

This forum is a extremely difficult to use in relation to this subject.


Joined: 2009-02-25
Posts: 18
Posted: Fri, 2009-02-27 06:29

THiss is not working.. how to change the maps xml from regenerating the limit?


Joined: 2006-02-15
Posts: 6
Posted: Fri, 2009-02-27 22:40

Hi, I am not sure I get you because Maps.xml is not changed. It is just stated that was automatically created from Maps.xml hence it may be an issue under certain circumstances. So it is a warning to consider the situation.

aklar's picture

Joined: 2009-06-22
Posts: 3
Posted: Mon, 2009-06-22 11:08

Thank you for this wonderful, short and precise how-to for a very common wish. I also changed the customfield/classes/Maps.xml just in case.

aklar's picture

Joined: 2009-06-22
Posts: 3
Posted: Wed, 2009-07-22 13:59

Also, it might be a good idea to increase the size of the input field. You can do that by following these simple steps:

1. if you haven't already, create a new directory called "local" in gallery2/modules/customfield/templates
2. copy the file gallery2/modules/customfield/templates/CustomFieldItemEdit.tpl into the directory just created
3. change the lines 30 and 31 (everything between "<input type..." and ".../>") to this:

<textarea cols="40" rows="8" name="{g->formVar var="form[fields][$field]"}">{$value}</textarea>

You can, of course change the size (cols and rows) to whatever you like.


Joined: 2005-11-25
Posts: 64
Posted: Fri, 2009-10-02 19:33

I am looking for a solution to this truncation in the original keywords field. This is because I keyword all my images in Lightroom before import, so need the IPTC data to be read into the keyword field. Presumably this cannot be imported into a custom field or am I missing something?


Joined: 2008-10-16
Posts: 7
Posted: Tue, 2013-03-12 19:21

As of today this solution doesn't work for me neither.

I followed each step scrupulously without success :
1. DB change
2. Change (and .xml by the way)
3. Clear DB cache

Whenever I enter some text longer than 255 characters in a custom field through the site admin, it will be truncated to 255 characters after saving.

I can nonetheless enter some longer text through PHPMyAdmin, and retrieve it through the site admin.

This is weird.

Gallery version = 2.3.2 core
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.4.4 apache2handler
Webserver = Apache
Database = mysqli 5.5.25, lock.system=database
Toolkits = Exif, Gd, Thumbnail
Acceleration = none, none
Operating system = Darwin iTom.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64
Default theme = matrix
gettext = enabled
Locale = fr_FR
Browser = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.160 Safari/537.22
Rows in GalleryAccessMap table = 34
Rows in GalleryAccessSubscriberMap table = 2637
Rows in GalleryUser table = 5
Rows in GalleryItem table = 2635
Rows in GalleryAlbumItem table = 63
Rows in GalleryCacheMap table = 0


Joined: 2008-06-13
Posts: 18
Posted: Mon, 2013-05-13 08:12

In Step 2a above, the instruction is to change some code in the customfield's module file Maps.Inc.
At the top of the Maps.Inc file is a note that says:

This file is automatically generated from Maps.xml by lib/tools/bin/generate-maps.php

I'm using Gallery 2.3.1 and cannot find the xml file in lib/tools/bin/generate-maps.php. Though I see it did not help user tompei above.

I thought that I should check this file since it will automatically create the Maps.xml file. If I can look at the code of generate-maps.php perhaps I can find the issue but I can't seem to find it. Since the instructions was pre-Gallery 2.3.1, was the php file renamed or the coded combined into some other file?

Of note is when I edited the g_value field in phpMyAdmin, there was a value in there that I changed to 500 but the system wouldn't change it but instead eliminated the previous value in the field. I however checked other data fields and it appears that none of them have values in them, so I don't think this is the problem either.

I would really like to get this field to work. Also, btw, I have uploaded to the latest Gallery on another server and I'm sorry to say that I would loose way to many changes and modules to upgrade to it. At least for now.

Diana Ricci

Here's my info:
Gallery URL =
Gallery version = 2.3.1 core
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.3.20 apache2handler
Webserver = Apache
Database = mysqlt 5.0.50, lock.system=flock
Toolkits = LinkItemToolkit, Thumbnail, Gd, Exif
Acceleration = none, none
Operating system = Linux web41c38 #3 SMP Mon Apr 15 17:17:12 EDT 2013 i686
Default theme = matrix
gettext = enabled
Locale = en_US
Browser = Mozilla/5.0 (Windows NT 5.2; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Rows in GalleryAccessMap table = 20995
Rows in GalleryAccessSubscriberMap table = 15394
Rows in GalleryUser table = 470
Rows in GalleryItem table = 9771
Rows in GalleryAlbumItem table = 2037
Rows in GalleryCacheMap table = 0