4

ok so, Im building a fancy pants wordpress theme and part of the theme has php getting image widths and using those numbers to resize page elements. It works fine on my local machine, but when I put the theme on my hosted server using cpanel, it doesnt work.

I get this error

Warning: getimagesize() [function.getimagesize]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/yoursite/public_html/wpsite/wp-content/themes/yourtheme/styles/login.php on line 7

Warning: getimagesize(http://yoursite.com/wpsite/wp-content/uploads/2012/11/logo1.png) [function.getimagesize]: failed to open stream: no suitable wrapper could be found in /home/yoursite/public_html/wpsite/wp-content/themes/yourtheme/styles/login.php on line 7

SO I thought if I made a php.ini file in the wordpress's root directory with this in it:

[PHP]
allow_url_fopen = 1

That would work, but it wont.

Is there anyway to get this to work?

rugbert
  • 11,603
  • 9
  • 39
  • 68
  • 1
    Ask your hosting provider. Putting a php.ini file in your site's path only works if the provider set it up to work that way. – WWW Feb 01 '13 at 18:12
  • 1
    why dont you use a local path instead of loading your own website via an url? – Green Black Feb 01 '13 at 18:14
  • + to Crontab: or this setting not allowed to be overwritten. –  Feb 01 '13 at 18:17
  • Im not loading my own website via url, thats just how WP is pulling the image. it loads the entire path apparently. I cant really ask my hosting provider to change it is the thing, Im making this theme for the general public so Im trying to make sure this works across the board. I guess Im going to have to find another way to get the image size... – rugbert Feb 01 '13 at 18:18

6 Answers6

9

Try to add this code to your .htaccess file:

php_value allow_url_fopen On

If it does not work, you will need ask your hosting provider about your php.ini file location, if it exists. If it does not, ask them to set this up for you in global php.ini file. Usually it's /etc/php.ini

John Smith
  • 186
  • 5
4

Other plugin developers seem to use cURL to get around allow_url_fopen restrictions. It is probably best for you to find a way to make your theme work without requiring allow_url_fopen to be enabled. Many providers turn this off for security reasons.

Sarah Kemp
  • 2,670
  • 3
  • 21
  • 29
1

None of these seemed to work on my host, and this is for a wordpress theme so it had to be a fix that could work for everyone so I just used jQuery. Tho if a users has their javascript turned off it wont work but I can live with that.

rugbert
  • 11,603
  • 9
  • 39
  • 68
1

Using cURL will bypass the issue. Some information and details that may be helpful can be found here:

PHP Curl And Cookies

Community
  • 1
  • 1
Doug
  • 6,446
  • 9
  • 74
  • 107
0

If you are on cPanel 11.58+ this is an option within the cPanel. You can do enable this by following these steps: 1. Login to cPanel. 2. Select "MultiPHP INI Editor" under the "Software" section 3. Select the domain you want to make this change for from the drop down 4. The first option will be "allow_url_fopen".

If you want to make the above change global in WHM you can so do something similar in multiphpini editor.

However, if you are on an older cPanel version you will have to edit your php.ini manually.

https://documentation.cpanel.net/display/ALD/MultiPHP+INI+Editor+for+cPanel

-2
allow_url_fopen = on

Add to php.ini or php5.ini

Works with Joomla 3.1 hope that helps.

pinckerman
  • 4,115
  • 6
  • 33
  • 42
Crazy
  • 1