Einzelnen Beitrag anzeigen
Alt 09.05.2008, 14:29   #5 (permalink)
cywhale
PostRank: 4
 
Registriert seit: 23.01.2007
Ort: Erlangen
Beiträge: 205
Man könnte den Filter 'post_gallery' eine eigene Galleriefunktion übergeben die dann auf das Bild in Rohform verweist oder ein eigenes Template o.Ä.

Nachteil ist dass man dann die komplette Gallerieanzeige auch implementieren muss...

Edit: Oder man gibt dem gallery-Shorttag eine neue Funktion (Overriding), das Original in /wp-includes/media.php:
Code:
add_shortcode('gallery', 'gallery_shortcode');

function gallery_shortcode($attr) {
    global $post;

    // Allow plugins/themes to override the default gallery template.
    $output = apply_filters('post_gallery', '', $attr);
    if ( $output != '' )
        return $output;

    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if ( isset( $attr['orderby'] ) ) {
        $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
        if ( !$attr['orderby'] )
            unset( $attr['orderby'] );
    }

    extract(shortcode_atts(array(
        'orderby'    => 'menu_order ASC, ID ASC',
        'id'         => $post->ID,
        'itemtag'    => 'dl',
        'icontag'    => 'dt',
        'captiontag' => 'dd',
        'columns'    => 3,
        'size'       => 'thumbnail',
    ), $attr));

    $id = intval($id);
    $attachments = get_children("post_parent=$id&post_type=attachment&post_mime_type=image&orderby={$orderby}");

    if ( empty($attachments) )
        return '';

    if ( is_feed() ) {
        $output = "\n";
        foreach ( $attachments as $id => $attachment )
            $output .= wp_get_attachment_link($id, $size, true) . "\n";
        return $output;
    }

    $listtag = tag_escape($listtag);
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
    
    $output = apply_filters('gallery_style', "
        <style type='text/css'>
            .gallery {
                margin: auto;
            }
            .gallery-item {
                float: left;
                margin-top: 10px;
                text-align: center;
                width: {$itemwidth}%;            }
            .gallery img {
                border: 2px solid #cfcfcf;
            }
            .gallery-caption {
                margin-left: 0;
            }
        </style>
        <!-- see gallery_shortcode() in wp-includes/media.php -->
        <div class='gallery'>");

    foreach ( $attachments as $id => $attachment ) {
        $link = wp_get_attachment_link($id, $size, true);
        $output .= "<{$itemtag} class='gallery-item'>";
        $output .= "
            <{$icontag} class='gallery-icon'>
                $link
            </{$icontag}>";
        if ( $captiontag && trim($attachment->post_excerpt) ) {
            $output .= "
                <{$captiontag} class='gallery-caption'>
                {$attachment->post_excerpt}
                </{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if ( $columns > 0 && ++$i % $columns == 0 )
            $output .= '<br style="clear: both" />';
    }

    $output .= "
            <br style='clear: both;' />
        </div>\n";

    return $output;
}
Die Idee ist interessant, soll das Bild an sich im Browserfenster geöffnet werden oder eine Templateseite mit dem Bild als Inhalt? Diese Variante ist für mich auch interessant, vielleicht setze ich mich dran falls Zeit bleibt.

Geändert von cywhale (09.05.2008 um 14:43 Uhr).
cywhale ist offline   Mit Zitat antworten