BlogInfo ('Template_Directory') IMG SRC
Domanda
Sono pigro caricando alcune immagini con URL che vengono aggiunti tramite campi personalizzati.
Il plug-in di carico pigro che sto usando richiede un'immagine del titolare del luogo in src
attributo e immagine effettiva in origini dati.
http://www.appelsiini.net/projects/lazyload
Ho bisogno anche dell'altezza e della larghezza dell'immagine, quindi ho usato wp_get_attachment_image_src()
.
Il mio problema è usare bloginfo('template_directory')
Per ottenere l'immagine trattenuta.
La prima immagine qui non mostra le immagini dei titolari del luogo ma emette l'URL nella pagina.
<?php
$attch_id_1 = pn_get_attachment_id_from_url(get_post_meta($post->ID, 'img1', true));
$image_attributes_1 = wp_get_attachment_image_src( $attch_id_1, 'full');
$attch_id_2 = pn_get_attachment_id_from_url(get_post_meta($post->ID, 'img2', true));
$image_attributes_2 = wp_get_attachment_image_src( $attch_id_2, 'full');
$attch_id_3 = pn_get_attachment_id_from_url(get_post_meta($post->ID, 'img3', true));
$image_attributes_3 = wp_get_attachment_image_src( $attch_id_3, 'full');
echo '<img src="'.bloginfo('template_directory').'"/images/img-BG.png" data-original="'.$image_attributes_1[0].'">';
echo '<img src="http://localhost/wordpress-cd/wp-content/themes/cd/images/img-BG.png" data-original="'.$image_attributes_2[0].'">';
echo '<img src="http://localhost/wordpress-cd/wp-content/themes/cd/images/img-BG.png" data-original="'.$image_attributes_3[0].'">';
?>
La fonte per la pagina sembra così.
http://localhost/wordpress-cd/wp-content/themes/cd<img src="/images/img-BG.png"
Perché non posso usare bloginfo('template_directory')
qui?
Come posso produrre correttamente le immagini?
Nessuna soluzione corretta