CCK Imagefield support
magoo - April 25, 2008 - 09:13
| Project: | #translatable |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I have a content-type that contains an CCK image field. The content-type is checked as translatable.
When I create a new translation, the image is not displayed (http://drupal.org/node/249204) and if I try to upload another image, it generates a fopen error.
Sometimes (depending on the node) the original image is displayed in the translation and sometimes not.
The image should be presented in the form (maybe with the upload button disabled for a first version) and the user should be able to translate the alt and title fields.
It is filed as a bug as #translatable is CCK-ready.

#1
From a high level view, the cause for this is that Imagefields are AHAH-enabled sub-forms in a node form. Also providing a multilingual solution for those fields is not trivial, since one might want to translate only the title + alt attribute (if enabled), and another one also wants to change/translation the image itself.
#2
So this means that there currently is no support at all for content-types containing CCK images!
This is important to say to potential future users because the CCK by design compatibility sentence is misleading.
Sad, as #translatable was my candidate of choice for multi-lingual sites and this could be a show stopper.
#3
As a workaround you can implement a form_alter() function in a custom module and set an imagefield to
'#translatable' => FALSE. This will hide Imagefields from the translation form, but use the same field values in translations.#4
Hello,
is there a comprehensive explanation on how to do this (form_alter) somewhere?
thanks in advance
#5
You might have a look at:
http://drupal.org/search/node/form_alter+type%3Abook
#6
I think I will go this way but from my point of view, the module should set
'#translatable' => TRUEonly for content types it is able to manage. (although I do not change the category, still from my point of view, this is a bug and not a feature request).And maybe produce a list of supported fields type.
my 2 cents,
magnus
#7
The
'#translatable' = > FALSEremoves the image fields from the translation form, which is fine.BUT
I have on the translation form an javascript error related to the imagefield
button has no properties misc/drupal.js
Line 31
redirectFormButton("<host>imagefield/js", undefined, Object button=#field-images-attach-button) drupal.js (line 31)
jsUpload("<host>imagefield/js", "field-images-attach-button", "field-images-attach-wrapper", "field-images-attach-hide") upload.js (line 27)
uploadAutoAttach() upload.js (line 14)
e([input#edit-field-images-attach-url.upload <host>ima...], function(), undefined) jquery.js (line 2)
e(function(), undefined) jquery.js (line 2)
uploadAutoAttach() upload.js (line 7)
e() jquery.js (line 2)
e() jquery.js (line 2)
e([function(), function(), function(), 12 more...], function(), undefined) jquery.js (line 2)
e() jquery.js (line 2)
[Break on this error] button.onmouseover = button.onfocus = function() {
Sorry for the bad copy paste.
Is this related to the way translatable "presents" fields that are
'#translatable' = > FALSE?#8
Alright. I was having the same JS error as you. For me, I'm doing some hackery and it got me into trouble with drupal.js .
For me, if in form_alter i changed an Imagefield from type $form['field_myimagefield']['#type'] from fieldset to 'value' to hide it on the form, I was getting this same error.
Simple fix to remove this error is to do a check in the drupal.js to make sure "button" exists before we try and do stuff with it.
Change line 31 in your drupal.js from this
Drupal.redirectFormButton = function (uri, button, handler) {// Trap the button
button.onmouseover = button.onfocus = function() {
to this
Drupal.redirectFormButton = function (uri, button, handler) {if(!button) {
return;
}
// Trap the button
button.onmouseover = button.onfocus = function() {
This resolves your JS issue.
--
Freelance Website Design