php - Javascript Tab Gallery with Advanced Custom Fields

I'm using Advanced Custom Fields on my site, i want to display pictures for my gallery field on a presentable, eleg

I'm using Advanced Custom Fields on my site, i want to display pictures for my gallery field on a presentable, elegant way. So i was thinking on do something like this:

.asp

My main issue is that i don't know how to put the php variables on the javascript code. Can you help?

The same css and the same script from the w3schools example, and this is my code:

<?php 

$images = get_field('extra_photos');

if( $images ): ?>
<div class="row2">
<div class="column2" >
<?php foreach( $images as $image ): ?>
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?> " onclick="myFunction(this);"/>
<?php endforeach; ?>    
</div>
</div>
<!-- The expanding image container -->
<div class="container2">
  <!-- Close the image -->
  <span onclick="this.parentElement.style.display='none'" class="closebtn">&times;</span>

  <!-- Expanded image -->
  <img id="expandedImg" style="width:100%">

  <!-- Image text  --> 
  <div id="imgtext"></div>
</div>


<?php endif; ?>

/

I don't know why it displays the pictures like one by one line, i want to display them all next to each other. How can i do it?

I'm using Advanced Custom Fields on my site, i want to display pictures for my gallery field on a presentable, elegant way. So i was thinking on do something like this:

https://www.w3schools/howto/howto_js_tab_img_gallery.asp

My main issue is that i don't know how to put the php variables on the javascript code. Can you help?

The same css and the same script from the w3schools example, and this is my code:

<?php 

$images = get_field('extra_photos');

if( $images ): ?>
<div class="row2">
<div class="column2" >
<?php foreach( $images as $image ): ?>
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?> " onclick="myFunction(this);"/>
<?php endforeach; ?>    
</div>
</div>
<!-- The expanding image container -->
<div class="container2">
  <!-- Close the image -->
  <span onclick="this.parentElement.style.display='none'" class="closebtn">&times;</span>

  <!-- Expanded image -->
  <img id="expandedImg" style="width:100%">

  <!-- Image text  --> 
  <div id="imgtext"></div>
</div>


<?php endif; ?>

http://electives-abroad/mnazi-mmoja-in-zanzibar-tanzania/

I don't know why it displays the pictures like one by one line, i want to display them all next to each other. How can i do it?

Share Improve this question edited May 6, 2019 at 3:06 Draws Ren Gundam asked May 6, 2019 at 2:14 Draws Ren GundamDraws Ren Gundam 251 gold badge2 silver badges6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Fixed it!

This is the resulting code:

<?php 

$images = get_field('extra_photos');

if( $images ): ?>
<div class="row2">

<?php foreach( $images as $image ): ?>
    <div class="column2" >
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?> " onclick="myFunction(this);"/>
    </div>
<?php endforeach; ?>    

</div>
<!-- The expanding image container -->
<div class="container2">
  <!-- Close the image -->
  <span onclick="this.parentElement.style.display='none'" class="closebtn">&times;</span>

  <!-- Expanded image -->
  <img id="expandedImg" style="width:100%">

  <!-- Image text  --> 
  <div id="imgtext"></div>
</div>


<?php endif; ?>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745522118a4631304.html

相关推荐

  • php - Javascript Tab Gallery with Advanced Custom Fields

    I'm using Advanced Custom Fields on my site, i want to display pictures for my gallery field on a presentable, eleg

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信