Reputation: 2157
Is there any way to remove the image size of the wp_get_attachment function?
I was trying the following code with no luck, trying to get it either 100% or nothing at all.
echo wp_get_attachment_image($variable, array(100 . '%', 100 . '%'));
EDIT
This is what I ended up with that works perfectly thanks to drew010.
echo '<img src="'.wp_get_attachment_url($variable).'" alt="'.get_the_title().'" />';
Upvotes: 3
Views: 4151
Reputation: 21
You can't use it this way: alt="'.get_the_title().'"
You must use esc_attr($attachment->post_title)
or the_title_attribute()
.
If the title has some html tags your alt attribute can crash your html outline. Trust me, a year ago I searched for over 1 hour this bug in some theme.
Upvotes: 0
Reputation: 69937
@Jrod has the correct answer IMO, but you can also just call
wp_get_attachment_url($variable);
which gives you the URL to the full image. Then you can simply construct your own HTML markup for displaying the image.
Upvotes: 3
Reputation: 12524
If you want the full size image you should use the following:
echo wp_get_attachment_image($variable, 'full');
Upvotes: 1