• 06-01-2015, 16:53:59
    #1
    Merhaba arkadaşlar.

    Ben upload edilen resimlerin alt metnini media.php'de nasıl çağırabileceğimi ve hangi değişkenle yazdırabileceğimi öğrenmek istiyorum.

    Yazdırmak istediğim kısım aşağıda;

    return '<h3>' . $atts['caption'] . '</h3><div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
    	. do_shortcode( $content ) . '<p class="wp-caption-text">' . $alt_metni_getirecek_degisken . '</p></div>';
    Yukarıdaki kodda $alt_metni_getirecek_degisken yerine hangi değişken yazılmalı ki resimlerin alt metni orada çıksın?
  • 06-01-2015, 18:14:12
    #2
    emlcvdv adlı üyeden alıntı: mesajı görüntüle
    Merhaba arkadaşlar.

    Ben upload edilen resimlerin alt metnini media.php'de nasıl çağırabileceğimi ve hangi değişkenle yazdırabileceğimi öğrenmek istiyorum.

    Yazdırmak istediğim kısım aşağıda;

    return '<h3>' . $atts['caption'] . '</h3><div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
    	. do_shortcode( $content ) . '<p class="wp-caption-text">' . $alt_metni_getirecek_degisken . '</p></div>';
    Yukarıdaki kodda $alt_metni_getirecek_degisken yerine hangi değişken yazılmalı ki resimlerin alt metni orada çıksın?
    üstte zaten parçalamışsınız gelen değerleri.
    wp-admin den incelediğinizde, http://prntscr.com/5p74w3 değerinin isminin post_excerpt olduğunu anlarsınız.

    $atts['post_excerpt']
  • 06-01-2015, 18:46:47
    #3
    _PatroN_ adlı üyeden alıntı: mesajı görüntüle
    üstte zaten parçalamışsınız gelen değerleri.
    wp-admin den incelediğinizde, http://prntscr.com/5p74w3 değerinin isminin post_excerpt olduğunu anlarsınız.

    $atts['post_excerpt']
    Cevap için teşekkür ederim hocam ama $atts['post_excerpt'] değişkeni resimlerin alt metnini çağırmıyor. Ya da ben yanlış anladım sizi. Skype varsa konuşabilir miyiz bu konuyu?
  • 06-01-2015, 19:01:56
    #4
    emlcvdv adlı üyeden alıntı: mesajı görüntüle
    Cevap için teşekkür ederim hocam ama $atts['post_excerpt'] değişkeni resimlerin alt metnini çağırmıyor. Ya da ben yanlış anladım sizi. Skype varsa konuşabilir miyiz bu konuyu?
    burdan yazarsanız herkes sebeplenmiş olur.
    Fonksiyonunuzun tamamını budan yazın lütfen.
  • 06-01-2015, 19:25:32
    #5
    _PatroN_ adlı üyeden alıntı: mesajı görüntüle
    burdan yazarsanız herkes sebeplenmiş olur.
    Fonksiyonunuzun tamamını budan yazın lütfen.
    Hocam şimdi media.php'de iki tane fonksiyon var. şöyle ki;

    1. Fonksiyon

    function get_image_tag($id, $alt, $title, $align, $size='medium') {
    
    	list( $img_src, $width, $height ) = image_downsize($id, $size);
    	$hwstring = image_hwstring($width, $height);
    
    	$title = $title ? 'title="' . esc_attr( $title ) . '" ' : '';
    
    	$class = 'align' . esc_attr($align) .' size-' . esc_attr($size) . ' wp-image-' . $id;
    
    	/**
    	 * Filter the value of the attachment's image tag class attribute.
    	 *
    	 * @since 2.6.0
    	 *
    	 * @param string $class CSS class name or space-separated list of classes.
    	 * @param int    $id    Attachment ID.
    	 * @param string $align Part of the class name for aligning the image.
    	 * @param string $size  Optional. Default is 'medium'.
    	 */
    	$class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size );
    
    	$html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" ' . $title . $hwstring . 'class="' . $class . '" />';
    
    	/**
    	 * Filter the HTML content for the image tag.
    	 *
    	 * @since 2.6.0
    	 *
    	 * @param string $html  HTML content for the image.
    	 * @param int    $id    Attachment ID.
    	 * @param string $alt   Alternate text.
    	 * @param string $title Attachment title.
    	 * @param string $align Part of the class name for aligning the image.
    	 * @param string $size  Optional. Default is 'medium'.
    	 */
    	$html = apply_filters( 'get_image_tag', $html, $id, $alt, $title, $align, $size );
    
    	return $html;
    }
    2. Fonksiyon:

    function img_caption_shortcode( $attr, $content = null ) {
    	// New-style shortcode with the caption inside the shortcode with the link and image tags.
    	if ( ! isset( $attr['caption'] ) ) {
    		if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
    			$content = $matches[1];
    			$attr['caption'] = trim( $matches[2] );
    		}
    	}
    
    	/**
    	 * Filter the default caption shortcode output.
    	 *
    	 * If the filtered output isn't empty, it will be used instead of generating
    	 * the default caption template.
    	 *
    	 * @since 2.6.0
    	 *
    	 * @see img_caption_shortcode()
    	 *
    	 * @param string $output  The caption output. Default empty.
    	 * @param array  $attr    Attributes of the caption shortcode.
    	 * @param string $content The image element, possibly wrapped in a hyperlink.
    	 */
    	$output = apply_filters( 'img_caption_shortcode', '', $attr, $content );
    	if ( $output != '' )
    		return $output;
    
    	$atts = shortcode_atts( array(
    		'id'	  => '',
    		'align'	  => 'alignnone',
    		'width'	  => '',
    		'caption' => '',
    		'class'   => '',
    		'alt'   => '',
    	), $attr, 'caption' );
    
    	$atts['width'] = (int) $atts['width'];
    	if ( $atts['width'] < 1 || empty( $atts['caption'] ) )
    		return $content;
    
    	if ( ! empty( $atts['id'] ) )
    		$atts['id'] = 'id="' . esc_attr( $atts['id'] ) . '" ';
    
    	$class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
    
    	if ( current_theme_supports( 'html5', 'caption' ) ) {
    		return '<figure ' . $atts['id'] . 'style="width: ' . (int) $atts['width'] . 'px;" class="' . esc_attr( $class ) . '">'
    		. do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>';
    	}
    
    	$caption_width = 10 + $atts['width'];
    
    	/**
    	 * Filter the width of an image's caption.
    	 *
    	 * By default, the caption is 10 pixels greater than the width of the image,
    	 * to prevent post content from running up against a floated image.
    	 *
    	 * @since 3.7.0
    	 *
    	 * @see img_caption_shortcode()
    	 *
    	 * @param int    $caption_width Width of the caption in pixels. To remove this inline style,
    	 *                              return zero.
    	 * @param array  $atts          Attributes of the caption shortcode.
    	 * @param string $content       The image element, possibly wrapped in a hyperlink.
    	 */
    	 
    	$caption_width = apply_filters( 'img_caption_shortcode_width', $caption_width, $atts, $content );
    
    	$style = '';
    	if ( $caption_width )
    		$style = 'style="width: ' . (int) $caption_width . 'px" '; 
    
    	return '<h3>' . $atts['caption'] . '</h3><div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
    	. do_shortcode( $content ) . '<p class="wp-caption-text">' . esc_attr($alt) . '</p></div>';
    }
    Benim sorum şu: 1. Fonksiyondaki esc_attr($alt) değişkeni resimlerin alternatif yazılarını çekebiliyorken 2. Fonksiyondaki esc_attr($alt) değişkeni bunu yapamıyor. esc_attr($alt) değişkenini 2. Fonksiyonda da etkin hale nasıl getirebilirim?