• Resolved ryankolalis

    (@ryankolalis)


    I have worked with MF2 for quite some time with no issues. recently I notices 2 of my sites having an issue with the image media field. The page displays no thumbnail, i have had this happen in the past, but the image still shows up on the front end. (not the end of the world). Now tho, images are not added to the front or back. I have tried many things:
    permalinks, permissions, fall back version of the plugin, hacks/mods suggested by others with troubles… Ive tried getting the image as get_image() and by just get() to see the image url. Still no luck. When I click on set image the media library pops up and works like normal. its not until you hit set image in the media manager that nothing happens. The popup closes and no image is set. When you hit update on the post, the page refreshes and you can see the image is broken. Also if you view custom fields (coreWP) you can see the meta key and the image url are active, but yet no image in the front end.

    Any suggestions would be greatly appreciated.

    Screen Shot

    https://www.ads-software.com/plugins/magic-fields-2/

Viewing 12 replies - 1 through 12 (of 12 total)
  • I have seen multiple reports of problems with Image Media Field from about six months ago. I have been trying to get a handle on this problem since then. I have not been able to duplicate this problem on my system. However, from all the problem descriptions I suspect that the Javascript code used to implement the setting of the image field from Media Library is not working. Can you look at the Javascript Console Log of your browser and see if there are any errors in it.

    I am highly motivated to solve this problem as Magic Fields 2 is a prerequisite plugin for my plugin and this has caused a problem for one of my users. Since, I cannot duplicate the problem myself I really need the help of a user which has this problem. If you can help me I will do my best to help you solve this problem.

    Question: When you got the “Forbidden” result were you trying to use a pre-existing image in the Media Library or did you upload a new image and try to use that. Can you try the other case and see if makes any difference?

    Magic Fields writes to the Javascript console every time you attach an image to an Image Media field. Is there a message like the following in your Javascript console.

    mf_use_new_image_gallery():attachment= alien_trespass.jpg

    If this message is not in your log then there probably is an error message in the log. That error message may be the key to solving this problem.

    After reviewing earlier reports of problems with Image Media I think your problem is different and is a server side problem not a Javascript problem. The “Forbidden” was probably returned by the server so the Javascript code apparently generated a request to load the image. Can you look at your browser network log for a request like the following:

    https://localhost:8080/wp/wp-content/plugins/magic-fields-2/thirdparty/phpthumb/phpThumb.php?&w=150&h=120&src=https://localhost:8080/wp/wp-content/uploads/2014/12/alien_trespass.jpg

    This is the AJAX request that the Javascript code would generate to load the image. Can you check if the src parameter is correct. Is the status code 403 Forbidden?

    Thread Starter ryankolalis

    (@ryankolalis)

    Hey Magenta Cuda, Thanks for looking into this
    I get this error on set image. I am able to upload images fine and i have tried using an image already uploaded, neither work.

    POST https://coreukdev.staging.wpengine.com/wp-content/plugins/magic-fields-2/admin/MF_ImageMedia.php
    403 Forbidden

    in response to the network log this is a 403 error i get

    Reload the page to get source for: https://coreukdev.staging.wpengine.com/wp-content/plugins/magic-fields-2/thirdparty/phpthumb/phpThumb.php?src=&w=150&h=120&zc=1

    I have other sites running on the same sever with no issue. I did however use a migrate tool? I’m just trying to figure out what is different than the others.

    For the

    POST https://coreukdev.staging.wpengine.com/wp-content/plugins/magic-fields-2/admin/MF_ImageMedia.php
    403 Forbidden

    what does the form data look like? It should look like

    image_id: "811"
    field_id: "testimage_1_1"

    where 811 should be the post id of an attachment and testimage is the name of your custom field.

    I noticed the src parameter in phpThumb.php is null it should be the URL of an image.

    “I did however use a migrate tool?” – Your problem may actually be a server configuration problem and not a Magic Field 2 problem. Does your server allow access to “https://coreukdev.staging.wpengine.com/wp-content/plugins/magic-fields-2/admin/MF_ImageMedia.php”?

    Thread Starter ryankolalis

    (@ryankolalis)

    Yes I can access that folder and file.

    In regards to the form data, i’m not sure where to find that information.

    For Firefox in the Network log click on the row of MF_ImageMedia.php then in the right pane click on Params.

    For Chrome in the Network log click on the row of MF_ImageMedia.php then in the right pane click on Headers and scroll down.

    For IE I don’t know but probably somewhat similar.

    Can you try this test? While logged in to your site can you enter
    https://coreukdev.staging.wpengine.com/wp-content/plugins/magic-fields-2/admin/MF_ImageMedia.php
    directly into your browser’s address bar. If I do this on my server I get the following output.

    Notice: Undefined index: image_id in C:\WWW\wp\wp-content\plugins\magic-fields-2\admin\MF_ImageMedia.php on line 23
    
    Notice: Undefined index: field_id in C:\WWW\wp\wp-content\plugins\magic-fields-2\admin\MF_ImageMedia.php on line 26
    {"image":"http:\/\/localhost:8080\/wp\/wp-content\/plugins\/magic-fields-2\/thirdparty\/phpthumb\/phpThumb.php?&w=150&h=120&src=","field_id":"","image_value":"","image_path":null}

    Since, in this case there was no form data sent errors were returned but it does show that the server actually ran the MF_ImageMedia.php PHP code. My wp-config.php has “define(‘WP_DEBUG’, true);” so your output maybe different if your wp-config.php is set differently but you should not get “Forbidden” error message if your server actually runs the code. If you get the “Forbidden” error message then I suspect your server is rejecting the HTTP request. There are two ways to get the 403 Forbidden response 1) the server can reject the HTTP request and return the 403 Forbidden response or 2) the server can pass the request to WordPress and WordPress finds something wrong with the request and returns the 403 Forbidden response. Since, some of your other sites work I think the server is rejecting the request.

    I ran another test with my wp-config.php with “define(‘WP_DEBUG’, false);” and not logged in and got the following output

    {"image":"http:\/\/localhost:8080\/wp\/wp-content\/plugins\/magic-fields-2\/thirdparty\/phpthumb\/phpThumb.php?&w=150&h=120&src=","field_id":"","image_value":"","image_path":null}

    which is what the code would generate with no form data. However, when I try

    https://coreukdev.staging.wpengine.com/wp-content/plugins/magic-fields-2/admin/MF_ImageMedia.php

    in my browser I get the following output

    Forbidden
    
    You don't have permission to access /wp-content/plugins/magic-fields-2/admin/MF_ImageMedia.php on this server.

    I searched the WordPress source code for the string “You don’t have permission to access” and it doesn’t exists so the error message was returned by the server and not WordPress.

    “…/wp-content/plugins/magic-fields-2/admin/MF_ImageMedia.php” is actually a very strange AJAX request. The usual way to do an AJAX request in WordPress is via “…/wp-admin/admin-ajax.php” where admin-ajax.php would invoke the AJAX handler. In other words, it is very strange that an AJAX request would go directly to “…/wp-content”. I would check that your server allows code to be directly executed from “…/wp-content”.

    Thread Starter ryankolalis

    (@ryankolalis)

    Thanks for all your help Magenta Cuda,

    I also get a forbidden error while logged in when going to that address on my server. I am talking to the server support. They said to pass this along to the developer

    [Tue Aug 25 15:19:27.734441 2015] [access_compat:error] [pid 31091] [client 66.162.212.19:63109] AH01797: client denied by server configuration: /nas/wp/www/staging/coreukdev/wp-content/plugins/magic-fields-2/thirdparty/phpthumb/phpThumb.php, referer: https://coreukdev.staging.wpengine.com/wp-admin/post.php?post=16422&action=edit
    
    [Tue Aug 25 15:19:27.756101 2015] [access_compat:error] [pid 31496] [client 66.162.212.19:63110] AH01797: client denied by server configuration: /nas/wp/www/staging/coreukdev/wp-content/plugins/magic-fields-2/admin/mf_upload.php, referer: https://coreukdev.staging.wpengine.com/wp-admin/post.php?post=16422&action=edit
    Thread Starter ryankolalis

    (@ryankolalis)

    I found a .htaccess file in my wp-content folder that was causing an issue. Removing this fixed my problem.

    Thanks for all your help

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Image Media Issue – Forbidden’ is closed to new replies.