marekbo12
Forum Replies Created
-
Forum: Plugins
In reply to: [ACF Photo Gallery Field] Gallery doesn’t display on some pages.Hey @navzme, do you know what is wrong?
Forum: Plugins
In reply to: [ACF Photo Gallery Field] Gallery doesn’t display on some pages.Hi.
Thank you for the quick reply.
If you need more information, code or link to my website – please tell me.Forum: Plugins
In reply to: [ACF Photo Gallery Field] Problem with adding custom CSS class to imageFixed code:
In display section:
<?php $images = acf_photo_gallery('gallery_images', $post->ID); if( count($images) ): foreach($images as $image): $id = $image['id']; /// here was a problem $class = get_field('gallery_images_class', $id); endforeach; endif; ?>
- This reply was modified 7 years, 6 months ago by marekbo12.
Yes, I resolved this yesterday.
I think you should add to Plugin Description “$id = $image[‘id’];”.Greetings
Hi, I have a problem with adding custom CSS class to image.
I added following code to functions.php file://Create extra fields called Altnative Text and Custom Classess function my_extra_gallery_fields( $args, $attachment_id, $field ){ $args['class'] = array('type' => 'text', 'label' => 'Kolor produktu', 'name' => 'class', 'value' => get_field($field . '_class', $attachment_id) ); // Creates Custom Classess field return $args; } add_filter( 'acf_photo_gallery_image_fields', 'my_extra_gallery_fields', 10, 3 );
next code in single-portfolio.php:
<?php $images = acf_photo_gallery('gallery_images', $post->ID); if( count($images) ): foreach($images as $image): $class = get_field('gallery_images_class', $id); endforeach; endif; ?>
and display this variable:
<?php foreach($images as $image) { ?> <img src="<?php echo $image['full_image_url']; ?>" class="<?php echo $class; ?>" > <?php } ?>
Nothing happend. What I am doing wrong?