Solved

add alt tag and width/height

Posted on 2010-11-11
1
423 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:Jon Imms
[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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

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…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. 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 : Go t…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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