html中imagefield做成链接,Using ImageField-Caption module as an easy HTML Caption ?

Attached is my patch on 7.x-1.82 field_slideshow.module to enable Image Field Caption captions for Field Slideshow captions.

I didn't spend too much time messing around with this, but I was able to get my Image Field Caption text to load as a caption with Field Slideshow width just a few lines of code. I needed this for a customer's commerce site; going with field collections was not an option, and although the Media module is installed 1) it appears Field Slideshow only yet supports Media 1.x (I have 2.x with File Entity—maybe I just didn't try very hard to see if it works), and 2) I needed the caption field on the product/node edit form (maybe this can be done with Media, but Image Field Caption seems simpler/easier).

At any rate, I got something that seems to work so far, and it sounds like other people would appreciate the integration as well. So I'm posting my patch here expecting/hoping that others can use it and that it might be improved to be committed to Field Slideshow in future releases.

Potential issues I didn't bother addressing, or even looking into at all really:

For the other field types, Field Slideshow expects a regular text field, not long text. Image Field Caption is a long text field—it seems to work fine, except lines aren't breaking as they normally would (HTML input in the caption field is in fact rendered). I don't know if there's any reason really to limit captions to regular text fields; in fact, I think enabling HTML and long-text fields is a benefit for at least some applications.

There may be a better way to make the conditional statements than checking for the module and the caption field setting, but maybe not. With field collection or media, we can rely on the field type, which we can't do using the Image Field Caption module.

It seems like the logic of the conditional statements makes the different caption sources mutually exclusive. Most cases, this wouldn't seem to matter. However, theoretically I could have an image field, using both the Media/File Entity modules and Image Field Caption (as in fact I do)—in this case, I might want the option of using a field on my Image file entity, or the caption field, depending on view mode, for example. I didn't need this flexibility, but it seems like a good idea to build it in.

Again, I didn't spend very much time on this, and didn't even really spend too much time looking into/familiarizing myself with the code for either modules. I don't expect this to be the best possible integration, but both modules seemed simple enough.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值