• I have made my own theme and I let wordpress generate its gallery. Now, I get something like this:

    <dl class='gallery-item'>
    			<dt class='gallery-icon landscape'>
    				<img width="1200" height="789" src="https://*****.com/wp-content/uploads/2013/08/61-1200x789.jpg" class="attachment-large" alt="6" />
    			</dt></dl>

    My forst question is, can I change this codea that wordpress generates? If so, where? It would be great if I could change it without any plugin. I would like to use the width and add it to styles. It would need to result it into this:

    <dl class='gallery-item'>
    			<dt class='gallery-icon landscape'>
    				<img width="1200" height="789" src="https://*****.com/wp-content/uploads/2013/08/61-1200x789.jpg" class="attachment-large" alt="6" style="max-width:1200px"/>
    			</dt></dl>

    Any suggestions where to change the gallery code?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    You want to add style="max-width:1200px" to the <img tag? Have you considered just applying that to the existing CSS tags? That may be easier than using a filter to add that class tag.

    If you can provide a link to a gallery then I could suggest the specific CSS.

    generally, you can code your own gallery code;
    add this to functions.php of your theme:

    remove_shortcode('gallery','gallery_shortcode');
    add_shortcode('gallery','custom_gallery_shortcode');
    
    function custom_gallery_shortcode( $attr ) {
    //your gallery code here//
    }

    for reference, the native gallery shortcode is in /wp-includes/media.php from line 659

    I’m having a similar issue here;
    https://dev.chalkhillresidency.com/
    user: [ redacted ]
    password: [ redacted ]
    I want the gallery as a whole to align left, but the image area seems to be defaulting to landscape.

    Any help would be much appreciated!
    Lee

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Changing gallery code. Is it possible?’ is closed to new replies.