The MU forums have moved to WordPress.org

How to Use Real URL Paths and Not Virtual URL Paths with the Image Uploads (14 posts)

  1. Mykall
    Member
    Posted 14 years ago #

    I've noticed that when I use the image uploader, the URL to the image ends up looking like this:

    http://example.com/files/2008/07/example.jpg

    Obviously this isn't a real directory - and the true URL is:

    http://example.com/wp-content/blogs.dir/1/files/2008/07/example.jpg

    However I use a theme where I have to copy and paste the URL of the image into a custom field for thumbnail creation. Putting the virtual URL doesn't work - but using the actual URL does work.

    Is there a way to set up WPMU to just use the actual URL when it displays in your site?

  2. lunabyte
    Member
    Posted 14 years ago #

    "However I use a theme where I have to copy and paste the URL of the image into a custom field for thumbnail creation. Putting the virtual URL doesn't work - but using the actual URL does work."

    Modification of the theme to look for the file in the upload path, then render the url would be a better approach than modifying MU.

  3. Mykall
    Member
    Posted 14 years ago #

    This is the pertaining code that calls the thumbnail creation:

    <?php if ( get_post_meta($post->ID, 'image', true) ) { ?> <!-- DISPLAYS THE IMAGE URL SPECIFIED IN THE CUSTOM FIELD -->
    
    <img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&amp;h=57&amp;w=100&amp;zc=1&amp;q=100" alt="<?php the_title(); ?>" class="th" />			
    
    <?php } else { ?> <!-- DISPLAY THE DEFAULT IMAGE, IF CUSTOM FIELD HAS NOT BEEN COMPLETED -->
    
    <img src="<?php bloginfo('template_directory'); ?>/images/no-img-thumb.jpg" alt="" />
    
    <?php } ?>

    What would you suggest to change there?

  4. Mykall
    Member
    Posted 14 years ago #

    Any ideas?

  5. Mykall
    Member
    Posted 14 years ago #

    Any thoughts?

  6. Mykall
    Member
    Posted 13 years ago #

    I'm using Wordpress MU v2.6.

  7. andrea_r
    Moderator
    Posted 13 years ago #

    I would think the lack of answers means people don't know.

  8. Mykall
    Member
    Posted 13 years ago #

    I guess I'm just not that easily discouraged :) There's always a solution. It's all a matter of helping each other out here and giving ideas, even if we might not know the exact way to fix things.

    I did some looking around and found this which may have some relevance to the issue I've been having:

    http://trac.wordpress.org/ticket/7308

    Hopefully this will get integrated into WPMU v2.6.1 and help fix that issue.

  9. coolgates
    Member
    Posted 13 years ago #

    I'm using WooThemes on WPMU and this is my current workaround to use the absolute URL for TimThumb.php:

    <a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><img src="/thumb.php?src=http://blogs.journalism.cuny.edu/wp-content/blogs.dir/<?php global $blog_id; echo $blog_id; ?>/<?php echo get_post_meta($post->ID, "image", $single = true); ?>&h=195&w=540&zc=1&q=95" alt="<?php the_title(); ?>" /></a>

    Then, in your post, the image custom field should be something like:
    files/2008/10/6-or-9-train.jpg instead of the full URL

  10. dwenaus
    Member
    Posted 13 years ago #

    i have very little experience with wordpress mu but I'm having trouble with the function get_post_meta() i can't seem to get it to work. maybe that is part of your problem?.

    however to get thumbnails working I have used this instead:

    function the_thumb() {
        if ( $images = get_children(array(
    		'post_parent' => get_the_ID(),
    		'post_type' => 'attachment',
    		'numberposts' => 1,
    		'post_mime_type' => 'image',)))
    	{
    		foreach( $images as $image ) {
    			$attachmenturl=wp_get_attachment_url($image->ID);
    			$attachmentimage=wp_get_attachment_image( $image->ID, 'thumbnail' );
    
    			echo $attachmentimage; // you can put attachmenturl in the href link if you want to link to the larger image
    		}
    	}
    
    }

    then just call the_thumb() in the loop

  11. takerlund
    Member
    Posted 13 years ago #

    @coolgates:

    I, too, am using Woo Themes. I appreciate you posting your work-around to get the thumbnails working, but when I tried your solution, I got an error:

    Parse error: syntax error, unexpected '<' in /usr/local/share/wordpress/wp-content/themes/flashnews/thumb.php on line 17

    Was I not supposed to put your code in thumb.php?

  12. domhodge
    Member
    Posted 13 years ago #

    I am also having this problem :), with a woothemes theme :)

  13. tstachl
    Member
    Posted 13 years ago #

    Hey guys,

    I have the solution ;-)

    $root = dirname(dirname(dirname(dirname(__FILE__))));
    if (file_exists($root.'/wp-load.php')) {
    	require_once($root.'/wp-load.php');
    } else {
    	if (!file_exists($root.'/wp-config.php'))
    		die;
    	require_once($root.'/wp-config.php');
    }
    function get_out_now() { exit; }
    add_action('shutdown', 'get_out_now', -1);

    if( !isset( $_REQUEST[ "src" ] ) ) { die( "no image specified" ); }

    // clean params before use
    $src = clean_source( $_REQUEST[ "src" ] );
    // set document root and clean "/files"
    $doc_root = substr(get_option('upload_path'),0,-6).$src;
    $src = "$root/$doc_root";

    Regards Thomas

  14. honewatson
    Member
    Posted 13 years ago #

    wp-content/blogs.php is very slow compared to serving the images directly.

About this Topic

  • Started 14 years ago by Mykall
  • Latest reply from honewatson