Great job on this module and on the new 2.0.

I notice that you added CKeditor support [1997964]. While this is probably a good thing in general, in my case I really prefer limit entries here to only plain text. In other fields, I'm able to select, on the content type form, whether to use plain text of a text editor (screenshot attached). Is it possible to expose this functionality for the Caption? If this issue is really outside the scope of this module, any advice is greatly appreciated. (I do have Better Formats installed...)

Thank you again!

Comments

squarecandy’s picture

Thanks for the great work here.
+1 on this feature request.

As a stop-gap solution I changed line 128 of image_field_caption.module so that it defaults to the plain text formater:

'#format' => isset($item['image_field_caption']) ? $item['image_field_caption']['format'] : 'plain_text',

I know that's not a great or portable solution, but it works for me for now...

I guess in terms of the feature request, it would be great to see an option in the settings to use just a plain '#type' => 'textfield' as an alternative to the '#type' => 'text_format' in the module. Seems like the full WYSIWYG or formatted textarea is probably overkill for most typical uses of this module.

aaronbauman’s picture

Title: Make ckeditor optional » Add configuration for default input format on caption field
Status: Active » Needs review
StatusFileSize
new1.92 KB

Attached patch adds an option on the field configuration to set the default input format on the image caption's text_format input field.

Fallback is the default input filter format, given by filter_default_format().
In other words, for existing installs, the current behavior will not be affected.

jakob123’s picture

Status: Needs review » Reviewed & tested by the community

Dear aaronbauman, thanks for the patch! Tested and works perfectly, very nice!

steven_kropp’s picture

Issue summary: View changes

Any hints as to just making the setting Plain Text as the default? I know I can just overwrite line 128, but I was wondering is there a hook alter form or anything like that... my PHP skills aren't super great, I've been trying to write a custom module for this ability but I can't seem to affect it.

jibus’s picture

Thanks for the patch !

Hope this will get commited soon !

ardarvin’s picture

+1 on waiting for a commit.

scotwith1t’s picture

+1 to see this committed too. My first attempt at using this module and having ckeditor pop up on these is certainly not needed and need a way to disable that! Thanks for a cool contribution! Patch works just fine so far.

awolfey’s picture

I'd like to offer an alternative patch. This patch adds a text_format settings field to set the default value and format for the caption. It shows the new field conditionally when Image Field Caption is enabled/checked for the image field.

wOOge’s picture

#8 applies and works.

peter panes’s picture

Thanks awolfey, #8 works for me to.

squarecandy’s picture

Status: Reviewed & tested by the community » Needs work

I tried #2 and #8 - I patched against latest dev. Using core 7.34 + wysiwyg + tinymce on input filter "Full HTML".

#8 is not working for me.

I get these php notices:
Notice: Undefined index: image_field_caption_wrapper in image_field_caption_field_instance_settings_form() (line 118 of .../sites/all/modules/image_field_caption/image_field_caption.module).
Notice: Undefined index: image_field_caption_wrapper in image_field_caption_field_instance_settings_form() (line 119 of .../sites/all/modules/image_field_caption/image_field_caption.module).

I get the new form for the default value, but no way to select a text format.

Surprised to see 2 people report it's working for them. Am I missing something?

#2 is working for me. Does not apply cleanly to current dev, but works once applied manually.

kreatil’s picture

I can confirm it is not working, as described by squarecandy in comment #11.

Using core 7.34 + wysiwyg + ckeditor. Although the selected text format is being memorized within the configuration of the image field, if I create a new node, always the system-wide default text format will show up.

awolfey’s picture

This patch fixes issues in #11 and #12. It's to be applied by itself, not on top of the previous patches.

Thanks.

awolfey’s picture

Status: Needs work » Needs review
kreatil’s picture

Patch #13 works for me. Using core 7.34 + wysiwyg + ckeditor.

tannerjfco’s picture

Status: Needs review » Reviewed & tested by the community

#13 is working for me as well.

tannerjfco’s picture

Status: Reviewed & tested by the community » Needs work

Actually, did hit an error with this when testing as an authenticated user without ability to change input formats:

Error message
Notice: Undefined index: format in image_field_caption_widget_process() (line 153 of sites/all/modules/contrib/image_field_caption/image_field_caption.module).
mkolar’s picture

#13 working for me, thanks!

istryker’s picture

New patch. Changes:

Added default settings to image_field_caption_field_info_alter(). You no longer need the isset check in image_field_caption_field_instance_settings_form().

In image_field_caption_field_widget_form_alter() it was overriding the image_field_caption enable setting with an array. #1 you should not overwrite something. #2 you should not change the type from an integer to an array.

@tannerjfco I cannot reproduce #17 problem. I tested with an authenicated user without the default format. As admin I set the default format to (Full HTML). I think is fix with me add the default settings to the field info.

istryker’s picture

StatusFileSize
new3.05 KB

New Patch fixes #2398237: If statement Control structure not following coding standard. (Cannot have 2 separate patches as they conflict).

joelhsmith’s picture

Patch #20 works for me. Using core 7.35 + wysiwyg + ckeditor. Thanks!

supermoos’s picture

Patch no longer applies on 7.x-2.x

skilip’s picture

Rerolled patch from #20 against 7.x-2.x.

tyler.frankenstein’s picture

Status: Needs review » Fixed

Thanks everyone. I added a hook_update_N() to set some sensible defaults for any existing image fields with captions enabled. I fixed a form #state bug, and also fixed a bug that would always display the caption, even if you later disable the caption on the field.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

vistree’s picture

Hi Tyler,
patch works great for a single instance image field. I use image field caption together with plupload to buld upload multiple files.
After using your new dev-version the input format is set to the field default just for the FIRST image. For all other images I receive the following error:

Notice: Undefined index: image_field_caption in image_field_caption_widget_process() (Line 199 from /sites/all/modules/contrib/image_field_caption/image_field_caption.module).
Notice: Undefined index: image_field_caption in image_field_caption_widget_process() (Line 201 from /sites/all/modules/contrib/image_field_caption/image_field_caption.module).

Do you have an idea on how to solve this error?

tyler.frankenstein’s picture

The short answer is to modify image_field_caption_widget_process() to have some default fall back values. The longer answer is to dig deeper into why there are no default values. Perhaps my latest update hook in image_field_caption.module isn't taking into account the scenario you describe. Either way, please open a new issue and reference this issue if the problem persists.

drupalgideon’s picture

Will this patch get rolled out into a proper release?

tyler.frankenstein’s picture

@SkidNCrashwell, does the latest development snapshot of the module work for you? If so, I'd be comfortable releasing a new version, I just wanted to hear from a few more people on whether or not this actually solves the problem.

vistree’s picture

Hi Tyler,
works for me - but as I wrote in #27 I receive erros for multi uploads.
I were able to solve this by https://www.drupal.org/node/2648938#comment-10796006
Is this something you could add to the patch?

Kostya19’s picture

After this commit there was an issue in multi-item field: when I remove one item, captions of all items are removed. The issue was solve by comment above https://www.drupal.org/node/2648938#comment-10796006

garbo’s picture

I can confirm Stay14's comment #32 and the solution he mentions.

tyler.frankenstein’s picture

Thank you everyone, I've applied the changes mentioned in #2648938: Using plupload assigns text format only to first image, grab the latest dev release of the module for this fix.