Problem accessing images in BP Album +


Cant find a similar post, apologies if already posted previously.

Blogs MU theme with bp album+ rotate

Selecting Album rotate in the theme options isnt working for me with the area of the page remaining blank.

In my apache log (debug mode) the path of the image its trying to locate is :

"redirected from r-uri = /wp.content/blogs.dir/1/var/www/wp.content/uploads/album/1/IMG_3516_1.jpg ...."

This corresponds to the function bp_album_featured_images_galley() and the path it looks for:

WP_CONTENT_URL = /wp.content
$myalbum->owner_id = 1
$myalbum->pic_org_url = in the database is stored as a full path from root

However, even if i take out everything but the final $myalbum->pic_org_url reference (so that it should get the correct path) still nothing is displayed, although it stops throwing errors into the log.

It might be that the following (image size is contributing)? ...

...the image that the function is calling in my error log is a full 6MB picture and not one of the smaller variants of the image in the album. BP Album+ appears to store 6 references to an image (and its size variants). One thing ive noticed in the database is that both the URL and the path references are both the same (a full path from the root directory). Would it be better for the function to lookup the mid-size image variant in the database on the basis that full size images might be large files (like mine)?

I assume from other posts this function is working for people without having to do what ive done above, so can you offer some suggestions as to what the problem is here please?

I look forward to your advice.

  • haylingpages


    In the BP Album+ settings in the Dashboard:

    Image URL re-mapping is set to "Yes"
    and the url is set to :

    Also :
    Album Image Size: 600
    Thumbnail Image Size: 150
    Keep original image: Yes

    Before making the settings above members couldnt see images they were uploading but with the above set they can. So I'm assuming this is correct.

    Also just in case (as im absolutely .htaccess ignorant), Ive included the rewrite section of my .htaccess file. I think its all pretty standard and doesnt look like it should be a factor:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

    ## add a trailing slash to /wp-admin
    RewriteCond %{REQUEST_URI} ^.*/wp-admin$
    RewriteRule ^(.+)$ $1/ [R=301,L]

    ## Added as wordpress SSL statement in wp-config.php not forcing various theme logins and registration to https
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\ HTTP/ [NC]
    RewriteCond %{HTTPS} !=on [NC]
    ## Following statement have taken out %QUERY_STRING immediately after %{REQUEST_URI} as it was duplicating the end of the re-mapped URL...
    RewriteRule ^/?(wp-admin/|register/|register\.php|login/|wp-login\.php){REQUEST_URI} [R=301,QSA,L]

    # uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
    RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule . index.php [L]

  • haylingpages

    You're still Online !! :slight_smile:

    OK taken the remapping off.

    I can no longer see images in my album (in "My Account"). Ive uploaded a new image with these settings on and it uploads but I cannot see this one either. the thumbnails are essentially empty containers.

    Also changes the theme settings to ablum rotate again to see if it picks up the images and this is still blank.

    Reverting back (for the timebeing) to re-mapping "Yes"

  • haylingpages

    Ive commented out the following rewrite condition for mapping to an index.php file in my htaccess file (in case it is masking a problem and hopefully to aid debugging) :

    # RewriteCond %{REQUEST_FILENAME} -f [OR]

    Im now spotting an error in my access log (but not error log for some reason) as follows:

    [30/Nov/2010:07:27:28 +0000] "GET /var/www/wp-content/uploads/album/1/Skull-Tattoo-Picture.jpg HTTP/1.1" 404 5716 "" "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv: Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10"

    Ignore the image name (its just a test file :slight_smile: )

    I'm now confused as this is the correct full path to the stored image, the file exists (correct name) and the file has the right ownership set and permissions for everyone to read the file.

  • Richie_KS

    ok..restore the htaccess and the bp album settings to your previous setting...i think it didn't have to do
    with htaceess and setting.

    do you have access to database mysql? if yes could you open up wp_bp_album, pick one of the img and list the following for me.

    - pic_org_url
    - pic_org_path
    - pic_mid_url
    - pic_mid_path
    - pic_thumb_url
    - pic_thumb_path

    want to make sure the path are correctly saved.


  • haylingpages


    Yep I host the site as well so have access to mysql.

    All of the picture paths and URL's are the same. They are all full paths to an image. eg :

    pic_org_url: /var/www/wp-content/uploads/album/2/img_8168.jpg
    pic_org_path: /var/www/wp-content/uploads/album/2/img_8168.jpg
    pic_mid_url: /var/www/wp-content/uploads/album/2/img_8168-600x400.jpg
    pic_mid_path: /var/www/wp-content/uploads/album/2/img_8168-600x400.jpg

    I have got this working now but have had to bodge the function code to the following (sorry im not a good php coder either :slight_smile: ):

    src= "<?php echo WP_CONTENT_URL . '/' . ltrim($myalbum->pic_org_url, "/var/www/wp-content"); ?>" />

    Had to do it that way as ltrim was removing characters from wp-content and the trailing "/" etc

    Is it all down to the fact that BP album+ is storing the url as a pathname ?

  • Richie_KS

    yeap the db saved were different from mine...what version of bp-album you're using..mine 0.1.8

    the code should work with your site....did the album single page also did not show? i mean the album gallery in your profile page...if not you may need to follow their htaccess instruction in bp-album setting.

    my db for wp_bp_album are like this *bold differ

    pic_org_url: /files/album/2/img_8168.jpg
    pic_org_path: /var/www/wp-content/uploads/album/2/img_8168.jpg
    pic_mid_url: /files/album/2/img_8168-600x400.jpg
    pic_mid_path: /var/www/wp-content/uploads/album/2/img_8168-600x400.jpg


  • haylingpages

    Odd! on version 0.1.8 as well according to the plug-in, but clearly its doing something different.

    Not sure what you mean by album gallery in the profile page, but I can see thumbnails of my images from My Account > Album > My Pictures, but only if I have the Image URL mapping set in BP Album+ setup (as described above).

    I have reverted back to all the original code in the functions.php file and set my site settings back to how I had them. I have added the redirect to my htaccess file that appears to be doing the job for the front page (but only if the member number for the album is #1 !!)

    Redirect 301 /wp-content/blogs.dir/1/var/www/

    this works as long as the member number remains as #1 but ive not idea how to replace 1 within a path statement with any valid number ...any ideas ?

  • haylingpages

    Right been playing with .htaccess and changed what I did originally (above).

    Ive now put in rewrite rules. Unfortunately the 2nd rule below, to cover the Blogs MU problem I started this post about, still doesnt work (probably my rubbish attempt at wildcards:

    # This rule works now for the BP Album+ essentially to re-enforce /var/www as the root directory:
    # I can take out the url remapping in the BP Album+ settings yipee!
    RewriteRule ^/?var/www/{REQUEST_URI} [R=301,QSA,L}

    # This or any combination of doesnt work, even if I take out the wildcards and hard code the member
    RewriteRule ^/?wp-content/blogs.dir/[0-9]+/{REQUEST_URI} [R=301,QSA,L}

    Basically with the rule above I'm looking to resolve the following from the source of my front page so that I can accommodate any image taken by the Blogs MU theme album rotate function :

    <div id="left-panel">
    <div id="intro-featured-img">
    <img width="100%" src="" />

    .....and even tackle again perhaps the /var/www/ part of this URL as well

  • haylingpages

    So I still dont really have a resoluton here?

    1. I still have the problem that because BP Album+ is storing a file location by its full path rather than a url from the site root, the album rotate function in the Blogs MU theme isnt retrieving my images from the upload folder.

    2. Also that the function is referencing the full size image which can ( and in my case actually is) a large image file, rather than the mid or small size images available in the album. The result is that the image is slow to load (even across a local network).

    Im trying to come up with a redirect to compensate for point 1 above, but even if I strike lucky on this, it still doesnt address point 2.

    Wouldnt it be better to have the function pull the mid size image by default? ...and if the URL field in the Album+ tables is potentially unreliable can the function not create a URL from the file path field instead ?

    I would be grateful for some further advice please.

  • Richie_KS

    btw didn't this edited code work as you mention it work ok?

    /// using bp album+ for featured images - buddypress only
    function bp_album_featured_images_gallery() {
    global $wpdb;
    $bp_album_feat_img = $wpdb->get_results("SELECT * FROM " . $wpdb->base_prefix . "bp_album WHERE privacy = '0' ORDER BY RAND() ASC LIMIT 1");
    if($bp_album_feat_img) {
    foreach($bp_album_feat_img as $myalbum ) { ?>
    <img width="100%" src="<?php echo WP_CONTENT_URL . '/blogs.dir/' . $myalbum->owner_id . $myalbum->pic_org_url; ?>" />
    <?php } }

    replaced with *bold is edited code

    /// using bp album+ for featured images - buddypress only
    function bp_album_featured_images_gallery() {
    global $wpdb;
    $bp_album_feat_img = $wpdb->get_results("SELECT * FROM " . $wpdb->base_prefix . "bp_album WHERE privacy = '0' ORDER BY RAND() ASC LIMIT 1");
    if($bp_album_feat_img) {
    foreach($bp_album_feat_img as $myalbum ) { ?>
    <img width="100%" src="<?php echo WP_CONTENT_URL . '/' . ltrim($myalbum->pic_org_url, "/var/www/wp-content"); ?>" />
    <?php } }

  • haylingpages

    no problem at all but I've run out of unique eMail addresse to register new names against (sorry not trying to be difficult) . Im a newbee to wordpress etc (if you hadnt gathered :slight_smile: ) but even in superadmin I still appear to need to provide a unique eMail. ...You OK to register on the website ( and if you need greater privileges I can up them for you if you let me know?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.