Bootstrap Image Box

By Timothy Foster Timothy Foster

Description

If you ever wanted a clean and simple way to add a caption or title to an image, this is the way to do it. The Image Box snippet allows you to decorate the display of an image and fit it to the theme of your website with code that is incredibly easy to remember.

In particular, the Bootstrap Image Box is a renovation over the old one. This snippet has been tailored to account for the power of the Twitter Bootstrap interface. Your images will now scale with differing screen widths so that users on all devices can have an excellent web experience.

Code

[[include :snippets:bs-image
|image=
|heading=
|caption=
|link=
|title=
|alt=
|max-width=
|width=
|float=
|force-float=
|kind=
]]

If you leave a field blank, then a default value will be applied. Therefore, it is not necessary to fill out all of the fields.

Note: Do not use quotes when filling out the fields.

Attribute Default Value Description
image Required! The URL of the image to be displayed.
heading Hidden The title of the image, displayed over the image itself.
caption Hidden Description of the image or its context, displayed under the image itself.
link The Image URL Web location that the user is directed to when the image is clicked. When supplied with a value of none, the link will be deactivated.
title Hidden Text that appears when the user hovers over the image long enough.
alt Image Unavailable Text that appears when the image at the specified URL does not exist.
max-width auto The maximum width the image should be. Scales when the screen width becomes small enough.
width auto Forces the image to always be at this width.
float middle Aligns the image to either the left or right.
force-float false When true, the image will always float regardless of screen size.
kind default Can be one of the Bootstrap predefined color schemes: primary, warning, danger, info, or success. Changes the scheme of the image box to that specified.

In action

Note: Your site must be Bootstrap-enabled to exhibit the full potential of this snippet!

You may see this snippet in action on the Bootstrap Playground. Try adjusting the screen width to observe how the image adapts!

Below is a quick snapshot of what the Bootstrap Image Box looks like along with the code that generates it.

wikidot_bs-image.png

[[include :snippets:bs-image
|image=http://timothyfoster.wdfiles.com/local--files/filestore:testimage/testImage.png
|heading=Sulphur
|caption=On the Periodic Table of Elements
|max-width=375px
|link=none
]]

CSS Customization

Like its predecessor, the Bootstrap Image Box may be easily customized for your site via CSS. Use the following classes for customization:

Class Description
image-box The overall Image Box
image-box-heading The heading area above the image
image-box-image The image area where the image itself resides
image-box-caption The caption area below the image

You may also use the following Bootstrap-specific classes that correspond to the kind field (see above):

Class
image-box-warning
image-box-danger
image-box-info
image-box-success

Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by Timothy Foster

Fancy HR Dividers - 07 Apr 2021 06:23
Carousel - 24 May 2015 01:18
Modal Image - 01 May 2015 17:20
Togglecheck - 17 Dec 2013 20:27
Alternative Specific Users Only - 11 Dec 2013 18:04
Image Box - 10 Dec 2013 03:14
Toggle Tag - 19 Jul 2013 11:13
Hide Tags - 14 Feb 2013 21:35
Plurality Checker - 16 Jul 2012 03:21
Mini Chat Area - 15 May 2012 12:04
Table Alterations - 16 Feb 2012 01:45


Rate this solution

If you think this solution is useful — rate it up!

rating: +18
Keith Bieszczat Keith Bieszczat 30 Apr 2025 14:16

1. Create a TXT record in your DNS configuration for the following hostname: _gh-Godstimetravelcorporation-e.scpf-foundation-roblox.fandom.com
2. Use this code for the value of the TXT record: d6409d998d. Please note that the code will expire in 7 days.
3. Wait until your DNS configuration changes. This could take up to 72 hours to propagate.


Keith bieszczat

by Keith Bieszczat Keith Bieszczat , 30 Apr 2025 14:16
A few questions
Norman Seversky Norman Seversky 06 Aug 2019 17:24

Hi folks!
I'm very new here, and have a couple of questions. Is there a way to make this image block wrapped by text (like it's done in a standard image wizard with floating positon. And another question - where do i put CSS customization to? Is it a separate field under this block or something "global"?

by Norman Seversky Norman Seversky , 06 Aug 2019 17:24
NoriMori NoriMori 18 May 2015 23:08

I changed my site to a Bootstrap-enabled one, and am using this snippet now; but the "clear,left" solution you gave me for making images float without the text wrapping doesn't work with this. Is there a way to do it?

Edit: Nevermind, it does work. It just wasn't showing in the preview.

Images still can't be stacked side-by-side though. ><

Last edited on 18 May 2015 23:19 by NoriMori
by NoriMori NoriMori , 18 May 2015 23:08
Timothy Foster Timothy Foster 19 May 2015 02:20

They can be stacked, but it is done using a table and putting the images in the cells. With Bootstrap, it can be conveniently done using their grid system, as I have it on this page. General syntax is as follows:

[[div class="row"]]
[[div class="col-sm-6"]]
IMAGE 1
[[/div]]
[[div class="col-sm-6"]]
IMAGE 2
[[/div]]
[[/div]]

Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me

by Timothy Foster Timothy Foster , 19 May 2015 02:20
NoriMori NoriMori 07 Jun 2015 19:54

Oooh, I'll try this out, thank you!

Edit: Works fairly well, though it's tedious to make images float where you want them to, and it doesn't seem to be compatible with making text wrap. ><

Last edited on 07 Jun 2015 22:46 by NoriMori
by NoriMori NoriMori , 07 Jun 2015 19:54
NoriMori NoriMori 19 Jan 2015 05:04

How do you make a site Bootstrap-enabled?

by NoriMori NoriMori , 19 Jan 2015 05:04
NoriMori NoriMori 18 May 2015 20:19

?

by NoriMori NoriMori , 18 May 2015 20:19
page revision: 5, last edited: 19 Jul 2014 01:27
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).

AltStyle によって変換されたページ (->オリジナル) /