Add class to wordpress image gallery
HTML
<div id="gallery-1" class="galy">
<dl class="gallery-item">
<dt class="gallery-icon">
<a href="#">
<img width="75" height="75" src="http://dummyimage.com/75x75/000/fff.jpg" class="attachment-thumbnail" />
</a>
</dt>
</dl>
<dl class="gallery-item">
<dt class="gallery-icon">
<a href="#">
<img width="75" height="75" src="http://dummyimage.com/75x75/000/fff.jpg" class="attachment-thumbnail" />
</a>
</dt>
</dl>
<dl class="gallery-item">
<dt class="gallery-icon">
<a href="#">
<img width="5" height="75" src="http://dummyimage.com/75x75/000/fff.jpg" class="attachment-thumbnail" />
</a>
</dt>
</dl>
<dl class="gallery-item">
<dt class="gallery-icon">
<a href="#">
<img width="75" height="75" src="http://dummyimage.com/75x75/000/fff.jpg" class="attachment-thumbnail" />
</a>
</dt>
</dl>
</div>
CSS
#gallery-1 {
margin: auto;
}
#gallery-1 .gallery-item {
float: left;
margin-top: 10px;
text-align: center;
width: 25%; }
#gallery-1 img {
border: 5px solid #cfcfcf;
}
#gallery-1 .gallery-caption {
margin-left: 0;
}
JavaScript
$(document).ready(function(){
$('div.gall').each(function(i) {
$('.attachment-thil').parent().addClass('view');
});
});