Mixmastermiike Mixmastermiike - 5 months ago 33
PHP Question

PHP syntax breaking the image tag

I am having an issue with my live site that works fine on a dev site (on a different host).

Essentially, it's brining in the image incorrectly and adding characters at the end... example:

it should just be: https://www.idealhomeloans.com/wp-content/uploads/2016/08/refinance-1.jpg

This is the php code I'm using to bring the image in...

<?php if( $image ): ?>

echo '<img class="'. $imagealigned.'" src="';the_sub_field('image');
echo '/>';


<?php endif; ?>

<?php $image = get_sub_field('image');
//Checking if anything exists for the image field
if ($image) { ?>
<?php echo '<img src="';// display a sub field value
echo '/>';
<?php } //if there is nothing for image then display
else { ?>
<?php }

Can someone who knows PHP well take a look and see if there's something that would render the image tag to come in correctly?

Any guidance would be greatly appreciated!



Perhaps if you actually LOOKED at the html you're generating, you'd see that you're generating BAD html:

echo '<img class="'. $imagealigned.'"     src="';the_sub_field('image');
                                              ^---start HTML attribute
echo '/>';
      ^----never end the attribute

So you're building

<img .... src="kittens.jpg>

and around and around the error merrygoround you go...