'Can I make random position for image every time I refresh page with php?
I need to make random position for every image when I refresh page. I’ve managed to do that to on my homepage so thumbnail pictures have different position with every refresh. They overlap a lot of the times, the code I used for random article position:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article style="left:<?php echo(rand(15,80));?>%; top:<?php echo(rand(0,80));?>%;"
<?php post_class('class-name');?>>
<?php if(has_post_thumbnail()) {the_post_thumbnail('medium');} ?>
<div class="post">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Read: <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
</div>
</article>
I have tried to apply the same logic to img/image but it doesn’t work.
Here is example how it should look like: example
Every pictures changed position is a new refresh, new layout for articles, but I can’t seem to do it with just images... Also tried with imagestring $x and $y positioning but it didnt work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
