Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




Images disappearing after attaching to post and php fatal error

UserPost

11:49 pm
June 5, 2011


AndrewM

Member

posts 17

1

I'm not sure how to fix this but if I log in as a user and upload an image it appears in their media library fine. However, as soon as I attach it to a post, the image disappears from their media library. If I then disable the plugin, I can see all the user's media files fine. Is there a setting somewhere that I'm missing?

Also if I enable the plugin I get the following php error:

PHP Fatal error:  Call to undefined method stdClass::merge_scoped_blogcaps() in /wp-content/plugins/role-scoper/role-scoper_init.php on line 121

6:49 am
June 6, 2011


Kevin

Admin

posts 2503

2

I think the fatal error is already fixed in the Role Scoper development code. Can you confirm that?

6:50 am
June 6, 2011


Kevin

Admin

posts 2503

3

AndrewM said:

I'm not sure how to fix this but if I log in as a user and upload an image it appears in their media library fine. However, as soon as I attach it to a post, the image disappears from their media library.


Can they edit the post that the image is attached to?

6:55 am
June 6, 2011


AndrewM

Member

posts 17

4

I'll install your dev version and see if that fixes the php error.

They can indeed edit the post that the image is attached to. It's a custom post type if that makes any difference, and I'm attaching the image/s to custom fields (about 5 total). If I view the media library as admin in another browser I can see that the author still has ownership over the file, but the under the "attached to" column it just has thi:

, 2011/06/06

7:01 am
June 6, 2011


Kevin

Admin

posts 2503

5

AndrewM said:

I'm attaching the image/s to custom fields (about 5 total).


Is another plugin involved in that? If custom template code, can you post it (or mail via contact form) for troubleshooting?

7:05 am
June 6, 2011


AndrewM

Member

posts 17

6

Ok installed dev version, no more php error :)

Have just sent you the full code on my php page that generates the metaboxes for uploading images (via your contact page).

8:15 am
June 6, 2011


Kevin

Admin

posts 2503

7

Andrew,

Your custom template code was saving the image attachments with a post_parent value of 1 (which corresponds to the "Hello World" post. Unexpected suppression the image from the Media Library listing was probably due to users' inability to edit that post.

You need to change your js code as follows:

from:

'media-upload.php?post_id=1&type=image&TB_iframe=true'

to:

'media-upload.php?post_id=<?php echo $GLOBALS['post']->ID;?>&type=image&TB_iframe=true'

8:08 pm
June 6, 2011


AndrewM

Member

posts 17

8

Thanks Kevin! I would never have known that. I tried the code (and changed the & to &amp;) but the firefox error console is saying "missing ) after argument list" and pointing to the word post.

I think I'll just remove the post_id bit altogether, seems to work now and I don't think I mind the image showing up as "unattached".

Thanks again

8:33 pm
June 6, 2011


AndrewM

Member

posts 17

9

Have no idea why (I'm not so good with JS) but this seems to work just fine and attaches the images correctly to the right posts.

    jQuery('#lt_upload_image_button_1').click(function() {
       
        window.send_to_editor = function(html) {
            imgurl = jQuery('img',html).attr('src');
            jQuery('#lt_upload_image_1').val(imgurl);
            tb_remove();
        }
       
         post_id = jQuery('#post_ID').val();
        
        tb_show('', 'media-upload.php?post_id='+post_id+'&amp;type=image&amp;TB_iframe=true');
        return false;
       
    });


About the Agapetry forum

Currently Online:

13 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1247

Posts: 5656

Members:

There are 1259 members

There are 1 guests


Kevin has made 2503 posts

Top Posters:

metal450 - 178

Ragnar - 108

YikYak - 70

whiteorb - 49

Daisy - 35

Administrator: Kevin | Moderators: Kevin