Default Gallery Output
-
I was trying to work on a theme. I found out that when generating a default gallery out put, the gallery shortcode adds some styling information just before the images like this
<style type='text/css'> #gallery-1 { margin: auto; } #gallery-1 .gallery-item { float: left; margin-top: 10px; text-align: center; width: 33%; } #gallery-1 img { border: 2px solid #cfcfcf; } #gallery-1 .gallery-caption { margin-left: 0; } </style> <!-- see gallery_shortcode() in wp-includes/media.php -->
I looked into the gallery_shortcode in wp_includes/media.php and found this code:
if ( apply_filters( 'use_default_gallery_style', true ) ) $gallery_style = " <style type='text/css'> #{$selector} { margin: auto; } #{$selector} .gallery-item { float: {$float}; margin-top: 10px; text-align: center; width: {$itemwidth}%; } #{$selector} img { border: 2px solid #cfcfcf; } #{$selector} .gallery-caption { margin-left: 0; } </style> <!-- see gallery_shortcode() in wp-includes/media.php -->";
I feel that instead of adding border to the #selector the borders should be added to .gallery-icon. By choosing to add it to #selector which will be gallery-1 or gallery-2, we make it difficult for theme authors to change the style of gallery output.
I was wondering if someone can explain to me why WordPress is using #selector to add borders to images in gallery and not a class like gallery-icon or gallery-item.
- The topic ‘Default Gallery Output’ is closed to new replies.