ฟิลด์ที่กำหนดเองของ Wordpress ที่แสดงชื่อรูปภาพ

ฉันมีช่องที่กำหนดเองซึ่งผู้ใช้สามารถเลือกพื้นหลังของ div ได้ อย่างไรก็ตาม ที่มุมขวาบนหรือหน้าจอจะแสดงสิ่งนี้:

35, , 4c5a6729201043.55e72a8144693, , , รูปภาพ/jpeg, http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693.jpg, 1200, 1200, อาร์เรย์');

รหัสที่ฉันใช้เพื่อให้ผู้ใช้เลือกพื้นหลัง (รวมถึงเนื้อหา) คือ:

<?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 ของ $image:

array (10) { ["id"]=> int (35) ["alt"]=> string (0) "" ["title"]=> string (28) "4c5a6729201043.55e72a8144693" ["คำบรรยายภาพ"] => string(0) "" ["คำอธิบาย"]=> 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) ["ขนาด"]=> array(9) { ["ภาพขนาดย่อ"]=> string(94) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-150x150.jpg" ["ขนาดย่อความกว้าง"]=> int(150) [" รูปขนาดย่อความสูง"]=> int(150) ["ปานกลาง"]=> string(94) "http://localhost:1337/kite/wp-content/uploads/2015/11/4c5a6729201043.55e72a8144693-300x300.jpg" ["ความกว้างปานกลาง "]=> int(300) ["ความสูงปานกลาง"]=> int(300) ["ใหญ่"]=> string(96) "http://localhost:1337/kite/wp-เนื้อหา/อัปโหลด/2015/11/4c5a6729201043.55e72a8144693-1024x1024.jpg" ["ความกว้างขนาดใหญ่"]=> int(900) ["ความสูงขนาดใหญ่"]=> int(900) } }

ภาพหน้าจอของมุมซ้ายบน

ภาพหน้าจอที่มุมซ้ายบน

ภาพหน้าจอของฟิลด์ที่กำหนดเอง ป้อนคำอธิบายรูปภาพที่นี่

ฉันจะกำจัดข้อความนี้ได้อย่างไร มันเป็นข้อผิดพลาดหรือไม่?


person 5kud    schedule 26.11.2015    source แหล่งที่มา
comment
เว็บไซต์ของคุณใช้งานได้แล้วหรือยัง? ฉันเดาว่ารหัสของคุณกำลังแสดงรายละเอียดของไฟล์รูปภาพ พยายามจำกัดให้แคบลงโดยแสดงความคิดเห็นเกี่ยวกับเสียงสะท้อนทีละรายการ   -  person Lucky Chingi    schedule 26.11.2015
comment
ไม่ ตอนนี้อยู่ในท้องถิ่นแล้ว แล้วมันต้องเป็นแนวนี้เหรอ? ‹div class=slide1 style=พื้นหลัง-ภาพ:url('‹?php echo $image['url']; ?›');› ฉันต้องการสิ่งนี้เพราะนี่คือสิ่งที่ทำให้ผู้ใช้ตั้งค่าพื้นหลัง div เป็นรูปภาพ   -  person 5kud    schedule 26.11.2015
comment
ทำ var_dump ของ $image แล้วโพสต์ไว้ที่นี่   -  person Lucky Chingi    schedule 26.11.2015
comment
อาร์เรย์ (10) { [id]=› int (35) [alt]=› สตริง (0) [ชื่อ]=› สตริง (28) 4c5a6729201043.55e72a8144693 [คำบรรยายภาพ]=› สตริง (0) [คำอธิบาย]=› สตริง (0) [mime_type]=› สตริง (10) รูปภาพ / jpeg [url]=› สตริง (86) localhost:1337/kite/wp-content/uploads/2015/11/ [width]=› int(1200) [ความสูง]=› int(1200) [ขนาด]=› อาร์เรย์ (9) { [ภาพขนาดย่อ]=› สตริง (94) localhost:1337/kite/wp-content/uploads/2015/11/ [ขนาดย่อความกว้าง]=›   -  person 5kud    schedule 26.11.2015
comment
int (150) [ภาพขนาดย่อความสูง]=› int (150) [กลาง]=› สตริง (94) localhost:1337/kite/wp-content/uploads/2015/11/ [ความกว้างปานกลาง]=› int(300) [ความสูงปานกลาง] =› int (300) [ใหญ่]=› string (96) localhost:1337/kite/wp-content/uploads/2015/11/ [ขนาดใหญ่-ความกว้าง]=› int(900) [ขนาดใหญ่-ความสูง]=› int(900) } }   -  person 5kud    schedule 26.11.2015
comment
ต้องโพสต์เกิน 2 ความคิดเห็นเพราะมันยาวเกินไป...คุณหมายถึงอะไร   -  person 5kud    schedule 26.11.2015
comment
คุณสามารถแก้ไขคำถามของคุณได้ :)   -  person Lucky Chingi    schedule 26.11.2015
comment
แก้ไขเป็นคำถามแล้ว ขอบคุณ   -  person 5kud    schedule 26.11.2015
comment
ให้เราสนทนาต่อในการแชท   -  person Lucky Chingi    schedule 26.11.2015


คำตอบ (1)


รหัสที่ถูกต้องถูกเพิ่มที่นี่

<?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 } ;?>
person Lucky Chingi    schedule 26.11.2015