Solved

add alt tag and width/height

Posted on 2010-11-11
1
408 Views
Last Modified: 2012-05-10
I have the following bit of code, which will display an image from the custom fields in wordpress.

<?php $image = get_post_meta($post->ID, 'image', true); 
		              if ($image > "0") { echo eval("?><img src=\"".$image."\"/><?"); } ?>

Open in new window


What i want to be able to do also, is automatically add alt tags, and have a default height and size so that the admin can just insert the image filename and not worry about resizing or adding alt tags.

how would i add the following to the above code?

alt="<?php the_title(); ?>" height="220" width="230" />

Open in new window

0
Comment
Question by:jonathan1978
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
AngryBinary earned 500 total points
ID: 34117017
Give this a try:

<?php
    $image = get_post_meta($post->ID, 'image', true);
    if ($image > "0")
    {
    ?>
        <img src="<?php echo $image; ?>" alt="<?php the_title(); ?>" height="220" width="230" />
    <?php
    }
?>
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pass foreach data in php into jquery ajax 10 46
How do use '  ' within this code? 4 27
Find RGB colors from a screen. 2 17
php output utf-8 problem 6 20
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question