Posted by heather on October 25, 2009 at 10:00am
| Project: | Lightbox2 |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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.
Thanks, Stella, for an awesome module.
Comments
#1
Shubshcribe.
#2
Subscribing. Very exciting! I'd be happy to help test and review patches.
#3
subscrib, great module for everyone.
#4
Subscribing.
I hope this will work ASAP.
#5
Subscribing.
#6
I 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.
#7
Thanks @origo, i'll test your patch and report back.
#8
I 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. ^_^
#9
@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
#10
@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
#11
@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
#12
The problem was because of another module , i updated it and now everything works fine. Thanks again
#13
Subscribing
#14
This 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. :)
#15
Doesn'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.
#16
Tested 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..#17
And for the record, the correct regexp is
/^lightbox2--((?:-(?!-)|[^-])+)--((?:-(?!-)|[^-])+)$/Tested with the following snippet of regress test :
<?php
function mtest($val) {
if (preg_match('/^lightbox2--((?:-(?!-)|[^-])+)--((?:-(?!-)|[^-])+)$/',$val,$matches)) {
print "$val => match 1 = $matches[1], match 2 = $matches[2]\n";
} else {
print "$val no match\n";
}
}
mtest("lightbox2--a-b--c-d");
mtest("lightbox2--ab--c-d");
mtest("lightbox2--a-b--cd");
mtest("lightbox2--ab--cd");
mtest("lightbox2--a-b-c--d");
mtest("lightbox2--a--b-c-d");
mtest("lightbox2--a-b-c-d--e");
?>
Attaching a new diff that works for me with my thumb-200px & thumb-640px presets.
#18
@#15 : or a cleaner and more lightbox2-ish way of integrating the caption in lightbox window would be using
<a rel="lightbox[group1][__description__]" href="<?php print $linkurl ?>">in lightbox2.insert-image.tpl.php instead of your suggestion of
<a rel="lightbox[group1]" title="__description__" href="<?php print $linkurl ?>">(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.
#19
landry,
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
#20
Suuuuubscribe! This is awesome.
#21
#17 working nicely so far
#22
Should we make this RTBC?
#23
If you guys think that #14 isn't too big a problem then I'd say yes. #17 worked for me.
#24
I 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 ?
#25
I didn't have any problem without flushing the cache before
I'm using Wysiwyg + FCKeditor
#26
So i guess there is a minor conflict with some other modules (Probably caching modules).
Making this RTBC then.
#27
one 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.
#28
Can you update the patch with the issue you mentioned ?
#29
Hi, 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...
#30
@origo That patch works perfectly fine. Thanks
#31
#32
Please notice: lightbox2.insert-image.tpl.php does not work in own theme directory. Discuss this here:
http://drupal.org/node/713424
#33
subscribing
#34
Regarding #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.
#35
#36
What exactly is this patch doing?
When will this be applyd to insert module?
#37
Patch in #34 works great, thanks!!
#38
Committed 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
#39
Great! thanks everyone
#40
Hi 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.
#41
The 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.
#42
I can confirm #41. Options show up but pressing "Insert" button doesn't insert anything. (using latest dev of lightbox2)
#43
Awesome! Subscribing!
Need functionality to open a different imagecache preset in the lightbox! Then insert WILL be killer!
#44
I 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
#45
Ah 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.
#46
I 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.
#47
OK, 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?
#48
Subscribing.
#49
subscribing
#50
subscribing
#51
Insert and Lightbox 2 running together is going to make my life so much easier!
#52
Friends, this is truly awesome, you've solved my image inserting problems, it looks and works great now! Thank you.
#53
#45 applies cleanly to latest lightbox2 dev and is working fine on 6.16 with all the latest other dev versions.
#54
$45 works great for me too. Thanks!
#55
Here'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.
#56
Can you post a full patch against the current dev version? I got confused by all this reverts and mods :)
#57
Actually that is a patch against the current dev version (just like the one in #45 was, and which it replaces).
#58
seems to work. :) thank you.
#59
subscribing
#60
This looks good! Thanks!
This is now (finally) committed to the dev version :)
#61
thanks 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
#62
The 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?
#63
Just installed the latest dev, flushed all caches, but when I add an image I cannot choose a lightbox style.
#64
have you checked the insert settings in the content type definition? i had the same issue with the patch..
#65
After 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.
#66
After upgrading, I had problems with the insert button not working, until I cleared all caches, so the new template was recognized.
Works great! Thanks!
#67
I 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.
#68
Subscribing. This is awesome! Thanks for this great patch!
#69
This 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?
#70
Sorry 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!
#71
There 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.
#72
OK, sorry for the confusion, and thanks for the help!
#73
#74
Subscribing. Love to have a release with that, though.
#75
If 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.#76
OK, 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".
#77
committed, thanks!
#78
Stella, 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
#79
You 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.
#80
stella, you're a gem! Thanks so much for your hard work on this, and everyone else who helped too.
#81
I had the same issue as #75. Just installed the latest dev.
Insert module works. Thanks!
Feature request: make Automatic insert style work with lightbox
#82
I'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
#83
Basically (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.
#84
I 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.
#85
@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
#86
origo, 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!
#87
Automatically closed -- issue fixed for 2 weeks with no activity.