The new Insert (formerly known as filefield-insert) module assists the creation of URLs to uploaded images so they can be placed inline. It's a really great way to work with imagefield and other file-fields (in my opinion).
This originally started as a feature request on that issue queue to support the CCK URL formatters.
http://drupal.org/node/479310
Quicksketch has now added support in Insert for CCK URL formatters, but it is up to each individual module to work with the hooks available in Insert. This includes Lightbox2. #60.
Now, Lightbox2 must include the necessary hooks to work with insert.
http://drupal.org/node/479310
Thanks, Stella, for an awesome module.
Comments
Comment #1
niklp commentedShubshcribe.
Comment #2
peterjmag commentedSubscribing. Very exciting! I'd be happy to help test and review patches.
Comment #3
ccrackerjack commentedsubscrib, great module for everyone.
Comment #4
Peter76 commentedSubscribing.
I hope this will work ASAP.
Comment #5
jhebel commentedSubscribing.
Comment #6
origo commentedI had a quick go at this and implemented the insert styles that I needed. It's not complete since I haven't implemented all the CCK formatters that lightbox2 provides. But it's a start.
Comment #7
sinasalek commentedThanks @origo, i'll test your patch and report back.
Comment #8
Geijutsuka commentedI am sold on Insert, Lightbox2 and ImageCache.
Will it soon be possible to click on an inserted image and have it open in a lightbox with another ImageCache preset (that is, without having to hand-code everything)?
Love you guys and your modules. They're such a big help to those of us who are Drupal-code challenged. ^_^
Comment #9
sinasalek commented@origo, Thanks for the sharing your patch it's what i was looking for, However i have some difficulty applying your patch. I suspect that maybe i'm applying it against wrong version. Would you please tell me which version of lightbox it's against?
Thanks
Comment #10
origo commented@sinasalek, The patch is for 6.x-1.9. I just tried it again just to make sure, it applied without errors:
[root@s1 drupal]# tar zxf lightbox2-6.x-1.9.tar.gz
[root@s1 drupal]# cd lightbox2
[root@s1 lightbox2]# patch < ../lightbox2.insertstyles.patch
patching file lightbox2.insert-image.tpl.php
patching file lightbox2.insert.inc
patching file lightbox2.module
Comment #11
sinasalek commented@origo
I could apply it under Linux, the problem was my patch utility in Windows sorry.
After enabling new lightbox 2 insert styles, i tried to use one of them to add an image to the content. It didn't work, with or without tinymce. (I can insert the image using the styles provided by imagecache module.)
Is there anything else i need to do other than applying the patch?
Drupal : 6.14
Lightbox : 1.9
Platform : Windows & Linux
Comment #12
sinasalek commentedThe problem was because of another module , i updated it and now everything works fine. Thanks again
Comment #13
srobert72 commentedSubscribing
Comment #14
Anonymous (not verified) commentedThis functionality would be great! Trying out the patch now (and subscribing ;) ).
Ed. Tested and works on Drupal 6.15 with WYSIWYG API/TinyMCE.
Ed 2. Make sure to *flush the cache* before trying to insert any images - it won't work if you don't.
Gr8 work, thank you. I finally found the most stable way for my users to handle inline images using CCK/insert/lightbox2. This really rocks. :)
Comment #15
Anonymous (not verified) commentedDoesn't take either title, alt or description text into account for caption text in lightbox. Adding ' title="__description__" ' in lightbox2.insert-image.tpl.php to the link calling the lightbox does the trick.
Comment #16
landry commentedTested patch from comment #6, works fine for me (thanks!), but a minor nit :
imagecache allows dashes in styles (say i have a 'thumb-200px' preset), whereas your lightbox2_insert_content() disallows that :
preg_match('/^lightbox2--([^-]+)--([^-]+)/',$style['name'],$matches)=> this one won't match "lightbox2--thumb-200px--original", and will return ''. And i was wondering why my own presets didn't work..Comment #17
landry commentedAnd for the record, the correct regexp is
/^lightbox2--((?:-(?!-)|[^-])+)--((?:-(?!-)|[^-])+)$/Tested with the following snippet of regress test :
Attaching a new diff that works for me with my thumb-200px & thumb-640px presets.
Comment #18
landry commented@#15 : or a cleaner and more lightbox2-ish way of integrating the caption in lightbox window would be using
in lightbox2.insert-image.tpl.php instead of your suggestion of
(if i got it right).. no ? That works for me too.
Now, another last issue with this patch... not hardcoding 'group1', to allow for several independent lightboxes in the same page.
Dunno what that would require in the drupal admin/edit ui.
Comment #19
Igal commentedlandry,
your patch in #17 works for me. The only problem that it uses absolute path to image and not relative.
After patch in #11 #622964: Provide UI option for using relative urls for the inserted images Insert module can use relative path and it is works for regular images and imagecache format, but not with patch you added for lightbox2
Comment #20
einkahumor commentedSuuuuubscribe! This is awesome.
Comment #21
hedac commented#17 working nicely so far
Comment #22
sinasalek commentedShould we make this RTBC?
Comment #23
einkahumor commentedIf you guys think that #14 isn't too big a problem then I'd say yes. #17 worked for me.
Comment #24
sinasalek commentedI had the same problem with the cache so i just checked the source code with my limited Drupal module development knowledge! i couldn't find anything that requires clearing the cache.
@origo , @landry do you know which part causes this problem ?
Comment #25
hedac commentedI didn't have any problem without flushing the cache before
I'm using Wysiwyg + FCKeditor
Comment #26
sinasalek commentedSo i guess there is a minor conflict with some other modules (Probably caching modules).
Making this RTBC then.
Comment #27
hedac commentedone minor bug I think this adds an space after the in the html
I found a blank line at the end of the template file. "lightbox2.insert-image.tpl.php" I removed the last line and it is ok now.
Comment #28
sinasalek commentedCan you update the patch with the issue you mentioned ?
Comment #29
origo commentedHi, I created a new patch taking into account the comments above. This patch builds on #17 above and:
- is a patch against Lightbox2 6.x-1.x-dev
- fixes #18, #27 above
- compatible with Insert 6.x-1.0-beta3 (#19 above, create absolute or relative paths)
Just a comment regarding #17: The choice of two dashes to separate the ImageCache preset names was arbitrary. Lightbox2 uses two underscores when it defines the CCK formatters, but that did not work well when defining Insert styles because Insert does replacements based on double underscores (__title__ etc.). So I chose two dashes instead...
Comment #30
taote commented@origo That patch works perfectly fine. Thanks
Comment #31
sinasalek commentedComment #32
drupalfan2 commentedPlease notice: lightbox2.insert-image.tpl.php does not work in own theme directory. Discuss this here:
http://drupal.org/node/713424
Comment #33
jerry commentedsubscribing
Comment #34
origo commentedRegarding #32, apparently theme template files should use dashes, not dots, in the filename.
Here's a new patch that just renames the theme template to lightbox2-insert-image.tpl.php.
Comment #35
origo commentedComment #36
drupalfan2 commentedWhat exactly is this patch doing?
When will this be applyd to insert module?
Comment #37
CirruZZ commentedPatch in #34 works great, thanks!!
Comment #38
stella commentedCommitted with a few changes. I changed lightbox2_insert_styles() to just call lightbox2_field_formatter_info() as they're essentially the same function - no point duplicating code.
Thanks for the patch!
Cheers,
Stella
Comment #39
sinasalek commentedGreat! thanks everyone
Comment #40
origo commentedHi Stella! Are you sure that call to lightbox2_field_formatter_info() will work? As you say lightbox2_insert_styles() is essentially the same function, but there were some differences:
1. lightbox2_insert_styles() used "--" instead of "__" to separate imagecache preset names. "__" doesn't work because the Insert module does regexp replacement based on "__", e.g. "__title__". And after doing these replacements, it removes any remaining strings beginning and ending with "__". Also, the code in lightbox2_insert_content() expects "--" as separators.
2. Some of the formatters in lightbox2_field_formatter_info() were commented out in lightbox2_insert_styles() because they were not implemented, so we don't want those to appear as insert options.
Comment #41
webavant commentedThe patch from #34 worked, but the latest version doesn't. It shows the various lightbox2+imagecache settings as options, but Insert doesn't insert anything.
Comment #42
Anonymous (not verified) commentedI can confirm #41. Options show up but pressing "Insert" button doesn't insert anything. (using latest dev of lightbox2)
Comment #43
jonthomas83 commentedAwesome! Subscribing!
Need functionality to open a different imagecache preset in the lightbox! Then insert WILL be killer!
Comment #44
pfx commentedI confirm that pacth from #34 work fine for me; but not the latest dev of lightbox2 nothing inserted.
I use :
insert 6.x-1.0-beta4
Wysiwyg 6.x-2.1 with CKEditor
Thanks for this great functionality
Comment #45
origo commentedAh well. Here's a patch that reverts the change made by stella in #38. Lesson learned: you should not make last minute changes to code without testing. Apply the patch to the latest lightbox2-dev.
Comment #46
stella commentedI still don't like that patch, because there is too much code duplication. Perhaps we can rework it so it pulls stuff from the imagecache formatter and use str_replace() to replace the __ with --. Will take another look this weekend.
Comment #47
origo commentedOK, but remember that some CCK formatters currently do not have Insert style counterparts (the parts that are commented out). Perhaps those omissions should be implemented, so that all formatting options are available in both cases?
Comment #48
izkreny commentedSubscribing.
Comment #49
rout commentedsubscribing
Comment #50
tomsm commentedsubscribing
Comment #51
TiG commentedInsert and Lightbox 2 running together is going to make my life so much easier!
Comment #52
NPC commentedFriends, this is truly awesome, you've solved my image inserting problems, it looks and works great now! Thank you.
Comment #53
cglusky commented#45 applies cleanly to latest lightbox2 dev and is working fine on 6.16 with all the latest other dev versions.
Comment #54
einkahumor commented$45 works great for me too. Thanks!
Comment #55
origo commentedHere's a new attempt to placate Stella, instead of the patch in #45 ;-)
This patch doesn't duplicate any code, instead it filters and reformats the CCK formatters.
Comment #56
lupus78 commentedCan you post a full patch against the current dev version? I got confused by all this reverts and mods :)
Comment #57
origo commentedActually that is a patch against the current dev version (just like the one in #45 was, and which it replaces).
Comment #58
Anonymous (not verified) commentedseems to work. :) thank you.
Comment #59
heddiw commentedsubscribing
Comment #60
stella commentedThis looks good! Thanks!
This is now (finally) committed to the dev version :)
Comment #61
heddiw commentedthanks for the great module, works fine - not yet tried the new dev, only patched with #55, but i still have one problem with it, and maybe i miss something:
i have imagecache/lbox2/insert/wysiwyg/tinymce installed, and i'd like to setup a content type with the feature:
- inserting only 1 image in the body, and with all imagefields hidden
- lightbox2 shows all the imagefields not just the inserted image
i've set lbox2 grouping rule for cck to node groupping and imagefileds creates the correct rel="lightbox[nid]... tag but inserted image has rel="lightbox[group1][description] tag.
do i miss any settings with lbox2? in other words, is there an easy way, to achieve this feature using lbox2 and insert?
the only way i know is to modify lightbox2-insert-image.tpl.php and change rel="lightbox[group1.." part and somehow insert nid there. but i'm not sure, if this is the best way.
(other than i dont know how to collect the nid at this point in the template, maybe some preprocess)
thx
Comment #62
rout commentedThe current dev version doesn't seem to work for me. I don't see any of the insert styles for the CCK insert field. It was working with the patch from #45, though.
Any idea why the lightbox styles aren't showing?
Comment #63
tomsm commentedJust installed the latest dev, flushed all caches, but when I add an image I cannot choose a lightbox style.
Comment #64
heddiw commentedhave you checked the insert settings in the content type definition? i had the same issue with the patch..
Comment #65
NPC commentedAfter upgrading to 6.0-1.9 the lightbox insert styles are missing (both when creating a node and from the "insert" configuration on the node type field settings), though the lightbox display styles (in node type fields configuration) are present... I don't use automatic field display though, so having ability to insert as a lightbox is important.
Comment #66
patrickharris commentedAfter upgrading, I had problems with the insert button not working, until I cleared all caches, so the new template was recognized.
Works great! Thanks!
Comment #67
tomsm commentedI have looked at the insert settings but I cannot find anything related to Lightbox.
What should the setting look like?
My insert module version is 6.x-1.0-beta4
Lightbox2 version is 6.x-1.x-dev (2010-May-06)
I cleared all caches.
Comment #68
xalexas commentedSubscribing. This is awesome! Thanks for this great patch!
Comment #69
NPC commentedThis is odd - why does 6.x-1.9 shows as released on 2009-Jan-08? Is it possible that this is a step back from a dev version that I installed in April (see reply #52), with the patch to lightbox2.insert.inc file? Version 1.9 does not even have that file, so I don't know where to look to see if the changes from dev+patch are even included there?
Anyway, all cache cleared, and still no lightbox insert styles on ImageField :( Does the new dev (from 2010-May-06) include it? Did anyone try it?
Comment #70
NPC commentedSorry for reopening this, but I can't see this change in 6.x-1.9 at all, would welcome any feedback on what I may be doing wrong. Thanks!
Comment #71
stella commentedThere is no change to 6.x-1.9. It's still only in the dev version. The required changes were committed to CVS, hence the changing of the status to fixed.
Comment #72
NPC commentedOK, sorry for the confusion, and thanks for the help!
Comment #73
stella commentedComment #74
boobaaSubscribing. Love to have a release with that, though.
Comment #75
boobaaIf an imagecache preset has an underscore in its name (which is explicity allowed, see the description at
admin/build/imagecache/add: Please only use alphanumeric characters, underscores (_), and hyphens (-) for preset names.), then insert settings does not list the appropriate lightbox2 items. If underscores in imagecache presets are replaced by hyphens, everything seems to be working - though I cannot seem to be able to find the place where I was forbidden to have imagecache presets with underscores in their names if I want to use lightbox2 & insert with them.Comment #76
origo commentedOK, I can see why that is happening. Here is a patch that adjusts the regexp used to extract imagecache names from the CCK formatter ids. This will allow you to use underscore in imagecache names. However, you should note that if you use consecutive underscores or hyphens (two or more) then it still won't work. This is because lightbox2 uses "__" and "--" as delimiters when constructing CCK formatter ids and Insert style ids. So "my_preset" and "my-preset" will work, but not "my__preset" or "my--preset".
Comment #77
stella commentedcommitted, thanks!
Comment #78
jonthomas83 commentedStella, is lightbox in a position to use it with insert and imagecache? If so, could you advise what it is I should do in order to start using it? Not quite sure where we are with the patches etc and which one to use?
I understand we may still be in development, but if anything is close to working, I'd like to give it a crack on my website.
Many thanks
Comment #79
stella commentedYou can either use the next release of the dev version of the module (available later today), or wait for the next official release, which I'm aiming to have out in the next week or so.
Comment #80
jonthomas83 commentedstella, you're a gem! Thanks so much for your hard work on this, and everyone else who helped too.
Comment #81
tomsm commentedI had the same issue as #75. Just installed the latest dev.
Insert module works. Thanks!
Feature request: make Automatic insert style work with lightbox
Comment #82
jonthomas83 commentedI've installed the new lightbox2 dev module and have insert installed too, don't know how to configure it to work with lightbox though. Is there any documentation about to explain how to set it all up?
Many thanks
Comment #83
origo commentedBasically (if I remember correctly):
1. Install ImageCache, CCK, ImageField, Insert and Lightbox2.
2. Define your ImageCache presets.
3. Edit a content type, add an image field.
4. When configuring the image field, there is an Insert section. Here you enable the Insert button, the Insert styles that you want to use, and the default style. You should see a list of styles with different combinations of ImageCache presets, with and without Lightbox2.
5. That's it. When you edit a post of the content type in question, you can attach an image. Next to the uploaded image you should see an Insert button and a drop-down list with the styles you selected.
Comment #84
andribas commentedI have installed 6.x-1.9.
4. When configuring the image field, there is an Insert section. Here you enable the Insert button, the Insert styles that you want to use, and the default style. You should see a list of styles with different combinations of ImageCache presets, with and without Lightbox2.
Imagecache presets were TRANSLATED, i.e. preset named small and appears as "маленький", same with medium and large names.
"medium-portrait" was not translated. In other admin UI like views and contemplate I can set small -> original (original translated) and so on - presets are not translated.
Please, DO NOT TRANSLATE preset names.
Comment #85
stella commented@andribas - you need to be using the dev version of the module in order to use the insert functionality, not 6.x-1.9 In addition, the translation problem you describe is a separate issue from what is being discussed here, so please open a separate issue for it rather than hi-jacking this one.
Cheers,
Stella
Comment #86
jonthomas83 commentedorigo, thank you! :)
I feel like all my Christmases have come at once! :) This truly is the best way of inserting images in Drupal without a doubt...surely!
Thanks to all who have worked so hard on this, it's awesome!