Support » Plugin: Multiple Featured Images » Alt + Title with fields

  • yfchild

    (@yfchild)


    Hi.

    First thanks for your work. I love your plugin. Thanks very much for it.

    Second, how I can insert alt + title in 1 feature image?

    I try this:

    <?php $image = kd_mfi_the_featured_image( 'featured-image-1', 'full');?>	
    <img src="<?php $image; ?>" title="<?php the_field('cat_item'); ?>" />

    But doesn´t work. Can you tell me the way how you will dit it?

    Thanks

    • This topic was modified 12 months ago by  yfchild.
    • This topic was modified 12 months ago by  yfchild.
Viewing 1 replies (of 1 total)
  • yfchild

    (@yfchild)

    Udpate for anyone need it with customs field :
    in your file content:

    <?php kd_mfi_the_featured_image ('featured-image-XXXXXXX', 'full');?>

    in your function.php

    function add_img_title( $attr, $attachment = null ) {
    
    	$img_title = trim( strip_tags( $attachment->post_title ) );
    
    	$attr['title'] = get_post_field ('title_item');
    	$attr['alt'] = get_post_field ('alt_img_item');
    	return $attr;
    }
    add_filter( 'wp_get_attachment_image_attributes','add_img_title', 10, 2 );
    
Viewing 1 replies (of 1 total)
  • The topic ‘Alt + Title with fields’ is closed to new replies.