[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

add alt tag and width/height

Posted on 2010-11-11
1
Medium Priority
?
439 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

656 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