在foreach中随机化Smarty数组

I am trying to randomize the array 'Small', 'Medium' and 'Large' but do not have the point to implement inside my code.

My foreach code:

{foreach $Item->images as $image}
    <img src="{$image->Small}" />
{/foreach}

Should I assign at first the arrays and than call them?

Any ideas what else I can use?

I have not actually used Smarty, but shouldn't you be able to use the PHP tag like this?

{php}
    $values = ['Small', 'Medium', 'Large'];
    $randKey = array_rand($values);
    // Do something ...
{/php}

In plain PHP, you can achieve what you want as simple as that:

<?php $values = ['Small', 'Medium', 'Large']; ?>
<?php foreach($item->images as $image) : ?>
    <?php $randKey = array_rand($values); ?>
    <?= <img src="{$image->{$values[$randKey]}}" />; ?>
<?php endforeach; ?>

Found out already how is possible with Smarty3.

{assign var=size value=['Small'=>'small','Middle'=>'middle','Large'=>'large']}

{foreach $Item->images as $image}
    <img src="{$image->{$size|array_rand}}" />
{/foreach}