BuddyDev

Search

Importing images crashes my website

  • Participant
    Level: Initiated
    Posts: 7
    Andrew on #16399

    I dont know what I am doing wrong here – I have created this function and attached it to the functions.php however when I try to execute it my entire website dies.

    
    function mpp_custom_deregister_default_gallery_view() {
    
    mpp_import_attachment(‘/opt/bitnami/apps/wordpress/htdocs/imageupload/uploads/image~2.jpeg, 40690);
    
    }
    
    add_action( 'mpp_init', 'mpp_custom_deregister_default_gallery_view' );
    

    I can execute other mediapress api functions like this but if I try to execute importing images to a gallery it crashes the website.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #16404

    Hi Andrew,
    Please use mpp_template_redirect instead of init. At init, not everything is setup. So, It might cause some issue.

    
    function mpp_custom_deregister_default_gallery_view() {
    	mpp_import_attachment('/opt/bitnami/apps/wordpress/htdocs/imageupload/uploads/image~2.jpeg', 40690);
    }
    
    add_action( 'mpp_template_redirect', 'mpp_custom_deregister_default_gallery_view', 11 );
    
    

    Also, your code was missing a quotation (‘). The file path should be a valid strig. In your case, It was not valid. So, That might be throwing error.

    The best way to debug is to set WP_DEBUG true in wp-config.php while developing.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 7
    Andrew on #16412

    Hmm doesent seem to be doing anything I have the image it is tested and loads, I run the code but nothing shows up in the gallery on the backend or frontend.

    when I save it into the functions.php the server instantly refreshes usually when I run mediapress code it takes some time to process and the page to reload

    I tried
    mpp_import_attachment
    mpp_import_file

    I tried relative path to the file & the server path nothing seems to be importing.

    mpp_import_file('/imageupload/userpics/29263/01.jpg', 40882);
    mpp_import_attachment('/imageupload/userpics/29263/02.jpg', 40882);
    mpp_import_file('/opt/bitnami/apps/wordpress/htdocs/imageupload/userpics/29263/03.jpg', 40882);
    mpp_import_attachment('/opt/bitnami/apps/wordpress/htdocs/imageupload/userpics/29263/04.jpg', 40882);
    
  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #16420

    Please enable WP_DEBUG and let me know the log message. It could be file permissions issue. I don’t see any other reason.

    Also, Please do not use ‘mpp_import_attachment’ this way. It does not import file. Its purpose is to import a WordPress attachment(with id).

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 7
    Andrew on #16425

    If it is a permissions issue then defiantly – We are running on google cloud everything is locked down by default. What directories and or files would need to be unlocked.

    Tried to run the WP_Debug but it is running on a multipress installation and I am not seeing an error.

  • Participant
    Level: Initiated
    Posts: 7
    Andrew on #16428

    I have been using the – MY CUSTOM FUNCTIONS PRO plugin to execute the mediapress code.

    It has to be a permission issue because database updates are fine.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #16432

    Hi Andrew,
    We need some way to debug it.

    Can you please take a look at this

    https://codex.wordpress.org/Debugging_in_WordPress

    and see if you can enable debugging and find something? Even if it is a permissions issue, it should log.

You must be logged in to reply to this topic.

This topic is: not resolved