WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] P2 media buttons not appearing (6 posts)

  1. Jeremy Herve
    Member
    Posted 4 years ago #

    Hi!

    I am running 3.0 alpha (latest build) and P2 on my local machine, and there is an issue witht he mdeia uploader buttons: their URL is http://localdomain.dev/wp-admin/http://localdomain.dev/wp-admin/images/media-button-image.gif, so you cannot see the images.

    I believe this is due to the functions below, but I can't figure out out to solve the issue: I can display the images by removing return P2::make_media_urls_absolute( ob_get_clean() );, but then the buttons won't work.

    function media_buttons() {
    		include_once ABSPATH . '/wp-admin/includes/media.php';
    		ob_start();
    		do_action( 'media_buttons' );
    		return P2::make_media_urls_absolute( ob_get_clean() );
    	}
    function make_media_urls_absolute( $string ) {
    		$string = str_replace( 'images/', P2::admin_url( 'images/' ), $string );
    		// This line does not work in .org
    		return str_replace( 'media-upload.php?', P2::admin_url( 'media-upload.php?p2-upload=true&' ), $string );
    	}

    Can somebody help me with that?

    Thanks!

  2. Jeremy Herve
    Member
    Posted 4 years ago #

    I can't seem to find any solution to that issue. I have looked, I have tried, but nothing...

    Any idea?

  3. Jeremy Herve
    Member
    Posted 4 years ago #

    Seems it is due to a recent modification for WordPress 3.0:

    http://core.trac.wordpress.org/changeset/13256/trunk/wp-admin/includes/media.php

    I keep trying , if anybody has any idea, let me know....

  4. Andrew Nacin
    Lead Developer
    Posted 4 years ago #

    I should probably work if you change it to return ob_get_clean();. There is no need for P2 to make URLs absolute anymore, as they are already absolute now.

    It appears the changeset broke an extreme edge use case -- P2 employs a very interesting hack in order to get the media buttons on the front end -- so I'm not too concerned. Automattic should be able to modify those two functions to allow it to work on both 2.9 and 3.0.

  5. Jeremy Herve
    Member
    Posted 4 years ago #

    Thank you! Yuo put me in the correct track!

    I have changed it, but unfortunately it did not complately solve the issue. The images had the correct path, but the links themselves had the wrong one: they had the format http://localdomain.dev/media-upload.php, missing the wp-admin there.

    So I have kept return P2::make_media_urls_absolute( ob_get_clean() );,, but I have removed $string = str_replace( 'images/', P2::admin_url( 'images/' ), $string );, and it seems to work.

    Thank you for your help!

  6. modifiedcontent
    Member
    Posted 3 years ago #

    Where are these lines? Which file are you talking about? Or is there another solution by now?

Topic Closed

This topic has been closed to new replies.

About this Topic