Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Step 1: Prepare your markup

Let's suppose you have some simple markup displaying your image 're using a <form> with hidden <input> elements to record the ordering of the images in your collections. A simple example of this could be:

Code Block
html
html
<form action="#" id="reorder-images-form">
    <div>">
    <a href="myImage1.jpg">
        <img src="myImage1.jpg" alt="image 1 thumbnail" />
        <span">Image 1</span>
        <input name="image 1" value="0" type="hidden" /> 
    </a>
    <a href="DragonfruitmyImage2.jpg">
 
          <img src="DragonfruitmyImage2.jpg" alt="Dragonfruitimage 2 thumbnail" />
        <span">Image 2</span>
         <span">Dragonfruit</span><input name="image 2" value="1" type="hidden" /> 
    </a>
    <a href="myImage3.jpg">
        <img src="myImage3.jpg" alt="image 3 thumbnail" />
        <span">Image 3</span>
        <input name="dragonfruitimage 3" value="02" type="hidden" /> 
    </a>
   </a>
    ...
</form>

The Image Reordeer needs to know about the 'container' of your image collection. In this case, that could be the <form> element. The Reorderer accepts a jQuery selector, so you can choose any method that will uniquely identify the <form> element. We'll attach a unique ID to it:

Section
Column
Code Block
html
html

<form action="#" id="reorder-images-form">
    ...
Column
Panel
borderColor#566b30
bgColor#D3E3C4
titleNote
borderStyleoutset

This example uses an ID, but you might, for example, use a CSS class, or the element hierarchy - whatever works, so long as it uniquely identifies the right element.

You also need to tell the Reorderer which of your images should be reorderable. Most of the time, that will likely be all of them, but perhaps you want the first image to always be first, since it's the cover of the album. For this tutorial, though, we'll make all of the image movable.

You'll tell the Reorderer which items are to be orderable with another jQuery selector. The Image Reorderer understands a default class name for this purpose. You can override that if you like, but for this tutorial, we'll go the simple route. The default classname is flc-imageReorderer-item, so let's add that to each of the <a> elements:

Section
Column
Code Block
html
html

<form action="#" id="reorder-images-form">
    <a href="
Dragonfruit
myImage1.jpg" class="flc-imageReorderer-item">
        
<img src="
Dragonfruit
myImage1.jpg" alt="
Dragonfruit
image 1 thumbnail" />

        
<span"
>Dragonfruit<
>Image 1</span>

        
<input name="
dragonfruit
image 1" value="0" type="hidden" /> 
    </a>
   
</a>
 <a href="myImage2.jpg" class="flc-imageReorderer-item">
        
<a
<img 
href
src="
Dragonfruit
myImage2.jpg" alt="image 2 thumbnail" />
        <span">Image 2</span>
        <input name="image 2" value="1" type="hidden" /> 
    </a>
    <a href="myImage3.jpg" class="flc-imageReorderer-item">
        <img src="
Dragonfruit
myImage3.jpg" alt="
Dragonfruit
image 3 thumbnail" />
        
<span"
>Dragonfruit<
>Image 3</span>

        
<input name="
dragonfruit
image 3" value="
0
2" type="hidden" /> 
    
</a>
    ...
...
</form>
Column
Panel
borderColor#566b30
bgColor#D3E3C4
titleNote
borderStyleoutset

As with the ID on the <form>, we can use any jQuery selector. For example, we could attach a unique ID to each movable <a> with a unique prefix, maybe pic-movable1, pic-movable2, etc. Then we could use the jQuery selector [id^=pic-movable] to override the default selector.

...

Step 2: Write the script

...

Step 3: Add the script to your HTML

...