Thread Starter
alowan
(@alowan)
I don’t think any of those works for the “gallery” function? Correct me if I am wrong..
And the columns problem seem to be a general bug? If I change it from 5 to etc. 2 it still shows 3..?
Thread Starter
alowan
(@alowan)
Somehow adding the
columns=”5″
to the gallery myself makes the gallery work right????
And my essential question, how do i REMOVE the default wordpress gallery css that seems to be overriding my generel css?
Edit: it seems it takes the value I entered and -2… So to get 5 columns I have to select 7..
Sorry perhaps i read your question a little too fast before and didn’t quite grasp what your issue is.
The embedded styling is in the source of the page, at a guess maybe the gallery shortcode pulls that in when it’s used in a post/page (view source and scroll down to where the images are you’ll see the styling placed just before those lines).
So i take it your page linked above is set to 8 images then?, since i see 6 images on the link you’ve provided above, would that be correct?
Thread Starter
alowan
(@alowan)
I also figured that it pulled it, the problem is that it pulls it from one of the core wordpress files and I can not figure out how to overwrite that styling.
The other issue is that in the admin panel when I select it to have 5 columns it shows me 5-2=3 columns (generally Number of columns – 2 = what it shows). I figure this is a problem in the danish wordpress – that it shows wrong numbers for the diffrent values. And I wonder how to change that.
The third issue is how to change the default column number to 5..?
The columns as it shows now (5 images pr. line – have 6 in gallery in totalt) is pretty much what I want.. Now I just want to figure out the columns issue + defeault columns, plus how to remove the wordpress core border and mouseover….
Hope that makes sence..
Thread Starter
alowan
(@alowan)
The clarify a bit more:
In regard to the styling I want the css in the top of this post changed to this:
<style type=”text/css”>
#gallery-1 {
margin: auto;
}
#gallery-1 .gallery-item {
float: left;
margin-top: 0px;
text-align: center;
width: 20%; }
#gallery-1 img {
border: 1px solid #cfcfcf;
padding:2px;
}
#gallery-1 img:hover {
border: 1px solid #333333;
padding:2px;
}
#gallery-1 .gallery-caption {
margin-left: 0;
}
</style>
So it fits my page..
But the code seems to be coming from the core of wp, and I can therefore not just insert this in my style.css
Thread Starter
alowan
(@alowan)
I just found this in the media.php of the core wp files:
$output = apply_filters(‘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;
}
And if I edit this the styling works..
But is there any way to not edit the core files?
And is there any way to fix the bug with columns..?
You see this part..
$output = apply_filters('gallery_style', "
This indicates a filter hook… π
So if you wanted to remove all that markup above, you could do this(purely as an example).
add_filter( 'gallery_style' , 'my_gallery_filter' );
function my_gallery_filter( $existing_code ) {
return;
//return $existing_code; // Uncomment the start of this line and remove/comment-out line above to fix(incase you're testing this code)
}
However you’d probably not want to remove all the markup, since it includes the opening DIV element that encompasses your gallery images, i’m simply showing you how you’d hook onto that filter.
I’ve not used a filter on that particular hook before, so i can’t give a better example right now. If you’re unable to make use the example above, let me know i’ll test some code and give a better example (can’t do that right now, have other things to get done).
Thread Starter
alowan
(@alowan)
Thank you for the reply.
So if I understand this right I could add this to my functions.php:
add_filter( ‘gallery_style’ , ‘my_gallery_filter’ );
function my_gallery_filter (
<style type=’text/css’>
#{$selector} {
margin: auto;
}
#{$selector} .gallery-item {
float: {$float};
margin-top: 5px;
text-align: center;
width: {$itemwidth}%; }
#{$selector} img {
border: 1px solid #cccccc;
}
#{$selector} .gallery-caption {
margin-left: 0;
}
</style>
<!– see gallery_shortcode() in wp-includes/media.php –>
<div id=’$selector’ class=’gallery galleryid-{$id}’>”);
To edit the default code to the code I want? (without having to edit core files)
Or am I misunderstading this?
I’m not sure those variables will work though.
The point of interest being that you can run a filter(avoid editting core files), so yes you can add it as a filter in your functions file.
If you get stuck let me know and i’ll try to find some time to take a look at writing a filter for you.
Thread Starter
alowan
(@alowan)
Hmm.. Something is wrong with my filter or the way I insert it..
When I insert it I get a blank white page and has to ftp the old functions.php back..
One approach is how the new wp 3.0 theme does it, and that’s to remove the styling and declare them in the stylesheet, here’s how that’s done.
In functions file: Inside the opening and closing php tags of the functions file, ie. <?php
and ?>
function twentyten_remove_gallery_css( $css ) {
return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
}
add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
In stylesheet:
.entry-content img {
margin: 0 0 24px 0;
max-width: 640px;
}
.alignleft,
img.alignleft {
display: inline;
float: left;
margin-right: 24px;
margin-top: 4px;
}
.alignright,
img.alignright {
display: inline;
float: right;
margin-left: 24px;
margin-top: 4px;
}
.aligncenter,
img.aligncenter {
clear: both;
display: block;
margin-left: auto;
margin-right: auto;
}
img.alignleft, img.alignright, img.aligncenter {
margin-bottom: 12px;
}
#content .wp-caption {
background: #f1f1f1;
color: #888;
font-size: 12px;
line-height: 18px;
text-align: center;
margin-bottom: 20px;
padding: 4px;
}
#content .wp-caption img {
margin: 5px;
}
#content .wp-caption p.wp-caption-text {
margin: 0 0 4px;
}
#content .wp-smiley {
margin:0;
}
#content .gallery {
margin: auto;
}
#content .gallery .gallery-item {
float: left;
margin-top: 10px;
text-align: center;
width: 33%;
}
#content .gallery img {
border: 2px solid #cfcfcf;
}
#content .gallery .gallery-caption {
margin-left: 0;
}
#content .gallery dl {
margin: 0;
}
#content .gallery img {
border: 10px solid #f1f1f1;
}
#content .gallery-caption {
color: #888;
font-size: 12px;
margin:-24px 0 24px 0;
}
#content .gallery br+br {
display: none;
}
sorry to jump in on this topic, but it’s closely related…
is it possible to use the functions.php to add a class to the 3rd <dl> outputted by the gallery shortcode?
hello,
i am having an issue where individual image thumbnails are being displayed differently to the thumbnails generated for a gallery.
when i look at the code in the page, for the gallery there is:
[gallery link="file" columns="4" orderby="ID"]
and for the single image there is:
[caption id="attachment_525" align="alignnone" width="150" caption="Caption Here"]<a href="http://www.path_to_image.com/2.jpg"><img src="http://www.path_to_image.com/2-150x150.jpg" alt="" title="Title" width="150" height="150" class="size-thumbnail wp-image-525" /></a>[/caption]
i have the following classes defined in my stylesheet but they don’t seem to be passing on to the gallery thumbnails:
.wp-caption
.wp-caption img
.wp-caption p.wp-caption-text
any ideas appreciated!
thanks!