• Resolved AleCss

    (@alecss)


    Hi, I’ve tried some solutions to add a custom class to featured image 2, but without success.

    Besides, in the html output my featured image 2 has not any #id. This the output html:

    <img width="1920" height="480" src="http://millennium.alecss.it/wp-content/uploads/2018/05/Belmonte-big.jpg" class="attachment-full size-full" alt="Belmonte collezione">

    I have tried tu use a function in my function-php to ad custom classes:

    function add_classes_featured_images() {
    	if ( kdmfi_has_featured_image( 'featured-image-2') ) {
        the_post_thumbnail('thumbnail', array( 'class' => 'animated' , 'fadeIn' ) );
    	}
    }
    
    add_action('x_after_view_global__slider-below', 'add_classes_featured_images', 10);

    But this doesn’t attach any new class.

    Can you help me please?

    Thank you very much

    Alex

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter AleCss

    (@alecss)

    I have tried to set classes using the kdmfi_the_featured_image arguments, but it doesn’t work.

    I show my second featured image with this action:

    function add_my_featured_image() {   
      if(is_singular('negozi-millennium')){
          kdmfi_the_featured_image( 'featured-image-2', 'full' );
      }
    }
    add_action( 'x_after_view_global__slider-below', 'add_my_featured_image', 10 );

    If I try to add an argument to kdmfi_the_featured_image the image is not viewable. Is not possible to set classes towards argumets? Does not work as shortcodes parameters?

    A part of my second featured image hasnt the default class, it has only “attachment-full” “size-full”. Also, it hasn’t no id.

    Can you help me please?

    Thank you

    Plugin Author Marcus Kober

    (@marcuskober)

    Hi there,

    my plugin doesn’t support this at the moment.

    But you are able to do a little workaround.

    Use the following code:

    function add_my_featured_image() {   
      if(is_singular('negozi-millennium')){
         $featuredImageId = kdmfi_get_featured_image_id('featured-image-2');
         echo wp_get_attachment_image($featuredImageId, 'full', false, ['class' => 'your-class-goes-here']);
      }
    }
    add_action( 'x_after_view_global__slider-below', 'add_my_featured_image', 10 );

    Regards,
    Marcus

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add a custom class to featured image 2’ is closed to new replies.