Neko T Farmer
Neko T Farmer

Reputation: 3

Removing The IMG SRC tag in Wordpress

I'm trying to remove the "img src" tag from the php so it'll simply display the images url, rather than displaying the actual image. This is the code I've got so far and it works perfectly, but when it's rendered it shows thumbnails instead of urls.

<?php $pics = get_post_meta( $post->ID, 'pics', true ); 
    foreach( $pics as $pics) 
    {
        $image_attributes = wp_get_attachment_image_src( $pics['pictures'] );
        echo '<img src="' . $image_attributes[0] . '" />';
    }
?>

I know theres a way to do this, but I don't know how to remove the tags without breaking the image code. Any help is appreciated.

Upvotes: 0

Views: 1310

Answers (2)

taloweb
taloweb

Reputation: 1

So do you want to show on the page the "html code" with the tag and the src attribute?

Have you tried to enclose "img" tag within "pre" tag?

echo '<pre><img src="' . $image_attributes[0] . '" /></pre>';

Upvotes: 0

Natalie Hedstr&#246;m
Natalie Hedstr&#246;m

Reputation: 2621

If you just want to echo the image src and not display it as an image then change

echo '<img src="' . $image_attributes[0] . '" />';

to

 echo $image_attributes[0];

<?php 

    $pics = get_post_meta( $post->ID, 'pics', true ); 
    foreach( $pics as $pics) 
    {
        $image_attributes = wp_get_attachment_image_src( $pics['pictures'] );
        echo $image_attributes[0];
    }

?>

Upvotes: 2

Related Questions