7

Directory Structure

I have customized my (local) install (dev box). The current directory structure is:

 ./root
  |- wp (WordPress Core root)
    \
    |- wp-config.php
  |- wp-content (Content and Vendor root)
    \
    |- mu-plugins (...)
    |- themes (...)
    |- plugins (...)
    |- uploads (Custom uploads dir)
    |- vendor (Composer installed libraries)
  |- index.php (loads ~/wp/index.php > require( dirname(__FILE__).'/wp/wp-blog-header.php' ); )

Config

In my wp-config.php, I have the following setup:

define( 'WP_SITEURL',      'http://example.dev/wp' );
define( 'WP_HOME',         WP_SITEURL );
define( 'WP_CONTENT_DIR',  './../../wp-content' );
define( 'WP_CONTENT_URL',  'http://example.dev/wp-content' );
define( 'WP_PLUGIN_DIR',   '../../wp-content/plugins' );
define( 'WP_PLUGIN_URL',   WP_CONTENT_URL.'/plugins' );
define( 'WPMU_PLUGIN_DIR', '../../wp-content/mu-plugins' );
define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL.'/mu-plugins' );

It is a single site install and none of the following constants is defined (and therefore falls back to default): UPLOADBLOGSDIR, UPLOADS, BLOGUPLOADDIR.

Filters

As @Sven (Hofmann) asked me in chat: The only plugin running on the *_url filters is one mu-plugin that sets up the new themes directory:

add_filter( 'theme_root_uri', 'switch_theme_root_local' );
add_filter( 'theme_root',     'switch_theme_root_local' );

As you can see, there's nothing that can conflict with internal URls.

Problem

Step 1) When I go to the "Media Library" and click/open an attachment, the modal opens like normal and displays the media file (or in the problematic case: the image).

Attachment Details - WordPress Media Library

Step 2) Hit the "Edit Image" Link above and the following screen (modal replacement) appears. Note the broken image. I opened Chromes dev tools to show the el and attributes/path.

Editing an Attachment - WordPress Media Library

I have no idea how to debug this and/or where the broken links origin could be. I assume that this is burried somewhere in WordPress least documented parts: JavaScript templates for the media library.

13
  • Are you using defined instead of define in wp-config.php ? I don't see this behavior on my skeleton installs.
    – birgire
    Commented Jan 6, 2015 at 9:11
  • @birgire No, that's just a typo. I use a .env-file and eited that out to not confuse anyone. Fixed.
    – kaiser
    Commented Jan 6, 2015 at 14:08
  • 1
    This is a sidenote, but I believe the console log error is a common one only to Chrome - Stack Overflow Question, Related Article.
    – Howdy_McGee
    Commented Jan 6, 2015 at 15:32
  • ok, I guess you could tackle stream_preview_image() ,armed with exit() and var_dump() ;-) ps: it also looks like you got a different setup than mine, since I don't use relative paths like './../../wp-content', so I guess your config file is in some subdirectory.
    – birgire
    Commented Jan 6, 2015 at 15:38
  • 1
    There are two cases of wp_die( -1 ); in the wp_ajax_imgedit_preview(), either from !current_user_can('edit_post', $post_id) or ! stream_preview_image($post_id).
    – birgire
    Commented Jan 6, 2015 at 16:40

1 Answer 1

1

The uploads dir has its own define in wp-config:

define( 'UPLOADS', WP_CONTENT_URL.'/customuploads' );

1
  • Thanks for the hint (updated my question to answer that), but I haven't defined it and it falls back gracefully to cores default. I haven't defined the MU constants either (it's a single site install).
    – kaiser
    Commented Jan 29, 2015 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.