I am trying to use substr to remove 4 characters from a URL string. The goal is to remove .jpg from the string and replace it with “-220×124.jpg”.
I am using a wordpress plugin, advanced custom fields, but that is not the issue here. The issue is that the subst is not working with the Advanced custom fields code, the_sub_field. It returns the entire URL string without the last 4 characters removed. Any idea why?
Code below:
<?php if(get_field('still_uploads')): ?>
<?php $i = 0; ?>
<?php while(the_repeater_field('still_uploads') && $i <= 0 ): ?>
<?php
$imagejesse = the_sub_field('still_image');
$imagejessenew = substr($imagejesse,0,-4);
?>
<?php echo $imagejessenew.'-220x124.jpg'; ?>
<?php $i++ ?>
<?php endwhile; ?>
<?php endif; ?>
You can see an example here: http://gicreative-dev.com/blog/genre/gay/
Use
strtr()
function like that:See this for a proof: http://ideone.com/B8ZQe
Try this: