Support » Plugins » Adding image size to an image hack

  • Hi
    I’ve been trying all morning to add the image sizes to an <img> tag.
    I’ve been using for a while this hack fond here: it’s been working great for me. But now i am trying to add the width and height to the HTML so jQuery can use it for some other code. Does anyone have an idea why this isn’t working?
    Thanks a lot!

    This code is on my functions.php page:

    /* thumbnails on archive pages */
    function the_thumb($size = "medium", $add = "") {
    	global $wpdb, $post;
    	$thumb = $wpdb->get_row("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_parent = {$post->ID} AND post_mime_type LIKE 'image%' ORDER BY menu_order");
    	list($w, $h, $type) = getimagesize($thumb);
    	if(!empty($thumb)) {
    		$image = image_downsize($thumb->ID, $size);
    		print "<img src='{$image[0]}' alt='{$thumb->post_title}' height='{$h}' {$add} />";

    and this code is ion the theme page – index.php:

    <?php echo the_thumb('thumbnail', 'class="alignleft"'); ?>

  • The topic ‘Adding image size to an image hack’ is closed to new replies.