Most of you have heard of Jquery Colorbox Plugin. Colorbox is a light-weight, customizable lightbox plugin for jQuery 1.3 through 1.6. In Drupal 7 colorbox jquery plugin is integrated with a module Colorbox.
# d+ _0 [6 G) M8 T' t2 `" r! o1 e, G" E/ C. w' m; q0 j4 C
Images, iframed or inline content etc. can be displayed in a overlay above the current page.
- h8 e6 \# i J* E9 l8 V- I6 d% V) y7 J0 |
" a2 q1 f) e2 w& E% C
# J: B" m$ U8 q+ _4 \9 r* S% h; W* I" \& G3 ~7 \; W; x- d
8 y1 a2 e/ E9 q' @* F
6 Z0 e6 S$ y( b! p& {( {% T
* b2 }7 i0 p0 V" q3 R( s, W" KFeatures
# Z0 l6 A( o" H" qThe Colorbox module:
, ~" T5 t2 I! u- l
2 W- C A: F" a/ v) xExcellent integration with Imagefield, Imagecache,Insert and Image modules
# W. N% a2 n1 [. D, q' Q8 `Choose between a default style and a number of other styles that are included.
6 h; ^% S3 @1 I% v7 R8 V1 Q$ w# SStyle the Colorbox with a custom Colorbox style in your theme.
% b0 H7 Q# ^ v# g* O1 z A( bOption to open a login form by clicking on any login link
$ G/ f" b% B% j4 g4 i" }* E/ `8 DDrush command to download and install the Colorbox plugin in sites/all/libraries as well as a Drush make file: A0 Z# _: T% s' t5 u- P: ?8 e* B& P
The Colorbox plugin:/ i; V( j! i' C) C: P/ v7 L
$ s# B& N: b1 Y9 F# sSupports images, image groups, slideshow, ajax, inline, and iframed content.8 w: y" H7 T5 R/ R
Appearance is controlled through CSS so users can restyle the box.
8 P" j7 t$ `% ?4 iPreloads background images and can preload upcoming images in a photo group.
5 b8 d5 D+ P5 A$ \* NNow lets use the colorbox module to show content images in a colorbox.
; k- j; y. g6 Z2 g# `+ X* i J' C6 K- O0 n- F2 H
Download the Colorbox module from drupal.org and place it in sites/all/modules folder.
# y, o, ]. y# U+ T) h
3 @7 L: b! S2 Y7 {) G/ `Go to Modules and enable the Colorbox module.
9 w" a1 V6 q; D* d8 |0 N. K4 V
1 ^. B1 s2 u: DDownload and unpack the Colorbox plugin in “sites/all/libraries”.
/ S6 Y8 p& O9 w4 wLink: http://colorpowered.com/colorbox/colorbox.zip
' A9 ?/ Y, P) Y- f& u4 \! T9 |( x: UDrush users can use the command “drush colorbox-plugin”.
4 X6 J! u, I9 p1 `- @$ P
5 r0 s y! r1 {# H4 DAdd two new presets by clicking on configuration-> Media ->Image Styles.; f: m9 ^! C; [+ P' E; S, h8 V
( ~( @' l2 G# f- o9 Q$ QSet the height and width of the presets accoiridng to your requirements.0 v! d! R8 L6 p( x
1 z! o8 H8 K8 e6 |
One preset will used for the preview image and the other one we use for the full image to be shown on colorbox.
1 p( V# H, v( x( ^$ Y( @( ?8 a4 _% R0 z6 _+ `8 `, K
Save both the image styles.
9 ^, m( @ h9 I' L) Z5 j/ I3 M& [4 j& M$ R
Create a new content type.
( K+ m1 O7 ^& K% b# P/ P1 W% U4 ~& F% N6 Y1 {8 w3 n; T
Add a image field to it.
2 v+ P7 X6 x, l. h( \
% i E0 s! x, rSelect the image preview style name we just created in the image styles. Here we will use the smaller image. to be shown on the listing page. Click save./ M8 ~% W6 c' ]) i5 l C
! ~% V0 d* m- O) A3 W' V2 }5 H' FAdd some images to the new content type we just created.
2 Z, B* r+ O/ i1 Q1 d1 d4 u( I6 S: D6 O
Create a view give it a name and continue with the default settings.
; Q/ N! D7 V5 f1 k9 ?9 j5 }$ V n0 h% H, g% W# k
* c/ ^: n/ g: m7 p1 @
; y5 @0 E2 z: P8 ^0 Z( X5 xApply the filter criteria by choosing the content name as the filter.) f' r4 {' X7 }9 o4 j
! g7 C# s$ \9 J
Now select fields to display in the view.# Z7 t/ S O. |6 \9 P3 z6 W
+ J, g8 u3 n" `3 |0 f7 f' I& g
Select Content Title and Content : Image Field Name as the fields.( D' z: k* k7 u( Z% W3 v3 [' u
$ O# ?. M* F& TIn the Image Field Name settings page enter a label name for the field.7 g" h0 B4 V8 n- Q* Y
) R+ F! H/ {* a7 _6 pIn the Formatter dropdown select the Colorbox option." u3 Z2 m( t& P1 i
6 D) D7 ~" L- L/ IIn the Node Image Style choose the name of the image style we created. Remember to use the smaller size for this field.
/ Q- `& y" c( L/ S3 T. M. g" Q) ^/ r, Z& ~& g3 ]0 c4 Y
In the Colorbox Image Style select the name of bigger image style.3 r" `% \$ X5 F* S! C1 C
* A+ m+ I; Z2 XClick save and save the views also.. l- W9 ~5 d+ \: h
* `3 d }0 M c: q: N1 k" DNow go back to the content type we have just created.9 g( Y. t3 j# Q% L6 @# g- P' K. d& w/ q1 w
Click on Manage Display Field.' D$ T6 [0 L {9 u3 H' z
2 u$ h: Z% M7 O. l0 f# I5 |7 BNext to Image field is a dropdown labelled as Format.
. P G+ g6 a' J5 |7 z1 A* |* }7 B' w
" r. q* _0 k( [5 bSelect Colorbox and configure the settings for the field.8 x Q1 d: K" b
$ r% y( e( g/ _. t, F- e) U
Node Image Style : Smaller Image style.
^. e# ]7 N& z
- Y' T0 A% f2 D1 `$ \% \# vColorbox Image Stye : Large Image Style.
, b3 J' G9 O/ P' E* ~7 f1 _+ D4 [% o7 R* r
Click Save.
8 e3 C+ J" K- K" o3 s5 Q6 ~, \7 E# o. u6 J; D8 E
Now you can see your images in a colorbox by clicking on them.
' o5 L7 l/ F; ]3 y9 W. ^
( m0 _% C' L2 B tYou can also use the Colorbox Stylesheets. Just copy the whole folder into your theme folder include in into your template files.
' B( G( e$ \' d0 ?7 A: P& m% a: N% p0 w; K& G! Y2 A0 v
With Colorbox plugin we can do lots of stuff with the images. This is the basic one to begin with. In the next post I will try to bring some advance usage with the Colorbox Plugin.& W. O0 {9 }9 w* m, Y2 `6 @, T
4 `! E: @3 W# a: y, ~- Y9 d- z
/ w3 W/ |3 c; `2 |( k
1 g' j8 g4 o" Z2 L' o
3 B/ ?' {' [' d% v5 ? O1 `3 ?
H4 R. G9 {9 r' X0 o8 z. | |
|