0

I have a custom field where the user can select the background of a div. However in the top right hand corner or the screen it displays this:

35, , 4c5a6729201043.55e72a8144693, , , image/jpeg, http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693.jpg, 1200, 1200, Array');

The code I am using to let the user select the background (as well as its content) is:

<?php $image = get_field( 'slide_bg1' );
if ( !empty( $image ) ) { ?>
    <div class="slide1" style="background-image:url('<?php echo $image['url']; ?>');">
<?php the_field('slide_bg1'); ?>');<div class="slide1-cont"><p class="slide-text"><h1><?php the_field('slide_title1'); ?></h1><img src="<?php bloginfo('template_directory')?>/images/line.png" /></p>
<p><?php the_field('slide_content1'); ?></p></div>
</div>
<?php } ?>

var_dump of $image:

array(10) { ["id"]=> int(35) ["alt"]=> string(0) "" ["title"]=> string(28) "4c5a6729201043.55e72a8144693" ["caption"]=> string(0) "" ["description"]=> string(0) "" ["mime_type"]=> string(10) "image/jpeg" ["url"]=> string(86) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693.jpg" ["width"]=> int(1200) ["height"]=> int(1200) ["sizes"]=> array(9) { ["thumbnail"]=> string(94) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-150x150.jpg" ["thumbnail-width"]=> int(150) ["thumbnail-height"]=> int(150) ["medium"]=> string(94) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-300x300.jpg" ["medium-width"]=> int(300) ["medium-height"]=> int(300) ["large"]=> string(96) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-1024x1024.jpg" ["large-width"]=> int(900) ["large-height"]=> int(900) } }

Screenshot of top left corner

screen shot of top left corner

Screenshot of custom field enter image description here

How do I get rid of this text? Is it an error?

9
  • is your site live? I am guessing your code is displaying the details of the image file. Try to narrow down by commenting out the echos one at a time Commented Nov 26, 2015 at 14:58
  • no it's locally at the moment. So it must be this line? <div class="slide1" style="background-image:url('<?php echo $image['url']; ?>');"> I need this as this is what lets the user set the div background as an image Commented Nov 26, 2015 at 15:03
  • do the var_dump of $image and post it here Commented Nov 26, 2015 at 15:10
  • array(10) { ["id"]=> int(35) ["alt"]=> string(0) "" ["title"]=> string(28) "4c5a6729201043.55e72a8144693" ["caption"]=> string(0) "" ["description"]=> string(0) "" ["mime_type"]=> string(10) "image/jpeg" ["url"]=> string(86) "localhost:1337/kite/wp-content/uploads/2015/11/…" ["width"]=> int(1200) ["height"]=> int(1200) ["sizes"]=> array(9) { ["thumbnail"]=> string(94) "localhost:1337/kite/wp-content/uploads/2015/11/…" ["thumbnail-width"]=> Commented Nov 26, 2015 at 15:14
  • int(150) ["thumbnail-height"]=> int(150) ["medium"]=> string(94) "localhost:1337/kite/wp-content/uploads/2015/11/…" ["medium-width"]=> int(300) ["medium-height"]=> int(300) ["large"]=> string(96) "localhost:1337/kite/wp-content/uploads/2015/11/…" ["large-width"]=> int(900) ["large-height"]=> int(900) } } Commented Nov 26, 2015 at 15:14

1 Answer 1

1

The correct code is added here

<?php $image = get_field( 'slide_bg1' ); 
if ( !empty( $image ) ) { ?> 
<div class="slide1" style="background-image:url(<?php echo $image['url']; ?>);"> 
<div class="slide1-cont"><p class="slide-text"><h1><?php the_field('slide_title1'); ?></h1><img src="<?php bloginfo('template_directory')?>/images/line.png" /></p> 
<p><?php the_field('slide_content1'); ?></p></div> 
</div> 
<?php } ;?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.