0

I'm having some issues with when applying image transforms. Hopefully it's something obvious I'm over looking. The code is as follows:

<picture>
    <source media="(min-width: 401px)" srcset="{{ imageUrl.getUrl('homeBanner') }}">
    <source media="(max-width: 400px)" srcset="{{ imageUrl.getUrl('iphone400x710') }}">
    <source srcset="{{ imageUrl.getUrl('iphone400x710') }}">
    <img src="{{ imageUrl.getUrl('iphone400x710') }}" alt="Image Desc">
</picture>

Images uploaded are all 2000px x 1330px and the transform should crop from center to the specified size in the handle.

My problem is it works on my local server but once uploaded to my (shared) dev server I am getting php out of memory errors on this script

craft/app/vendor/imagine/imagine/lib/Imagine/Gd/Image.php on line 617

Am I doing something incorrectly that is causing the script to run for too long?

Cheers

  • 1
    Since you are on a shared system, the php_execution_time or memory_limit might be set lower than what you have locally. See if increasing php_value max_execution_time and/or php_value memory_limit helps. – Damon Mar 8 '16 at 18:57
  • @damon thanks but where would I set these? I know you can add 'phpMaxMemoryLimit' => '512M', to the general config file but there doesn't seem to be anything for the other 2 you suggest? – Lettie Mar 8 '16 at 20:28
  • Ah shoot, that would have been helpful info - sorry about that. @RitterKnight has the right stuff. – Damon Mar 8 '16 at 21:15
  • No worries as you say @RitterKnight has been very helpful. – Lettie Mar 8 '16 at 21:49
1

You might try putting putting something like:

<IfModule mod_php5.c>
  php_value max_execution_time "30" 
  php_value memory_limit "256M"
</IfModule> 

inside your .htaccess. file.

You can tell what your PHP values are right inside Craft... unless you changed your admin trigger, just visit http://server/admin/utils/phpinfo and search for memory_limit and max_execution_time. That'll give you some clues as to what's going on.

Some hosts set these values really low but the default execution time is 30 and memory limit is 128M.

If you run PHP as a cgi, some hosts allow you to use ini files in lieu of .htaccess. Typically these are at the root of your home folder but they could be stored elsewhere. Put memory_limit = 256M in one and throw it up in your home folder. Running php_info() would tell you the location of the current in use one.

| improve this answer | |
  • thanks. Tried adding to htaccess but no joy. Looking at the limits though in craft they are already set to max_execution_time 50000 memory_limit 120M I have noticed that I now have a notice in the admin panel saying generating pending image transforms which doesn't seem to be moving? – Lettie Mar 8 '16 at 21:02
  • How are you running PHP? Craft doesn't expose that very well but it'll say apache2handler somewhere if it's running it as mod_php or cgi-fcgi if you're running it via cgi. You may even be running nginx via PHP-FPM. (Right below cgi-fcgi it'll say php-fpm if you are running that way.) Not all hosts support changing php_value through .htaccess. You might have to go in via a control panel to do that or contact an admin. – RitterKnight Mar 8 '16 at 21:12
  • I find Settings -> Clear Caches works wonders a lot too. – RitterKnight Mar 8 '16 at 21:14
  • Yeah already tried clearing the cache. Looks like cgi-fcgi nothing else gets picked up on a find. Changing php settings via the control panel is unlikely not seen anything in there and more than likely locked down as you suggested. – Lettie Mar 8 '16 at 21:19
  • You got one more option. Make a new file called php.ini. Put memory_limit = 256M in it and throw it up in your home folder. Some hosts will use that instead of .htaccess. It could be elsewhere as well. Craft doesn't expose that but if you call phpinfo() it'll show the loaded configuration file. That might be a clue. – RitterKnight Mar 8 '16 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.