Image Resizing Script required - a better one...
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Image Resizing Script required - a better one...
Also it looks like if I change the [] fpr (), I cannot use =>.............. ?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Image Resizing Script required - a better one...
Where? getWidths? Just return array() instead of [].simonmlewis wrote:ahhhhhhhhhhhhh
So for now, how do I edit the $widths to accept it on this server until we update?
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Image Resizing Script required - a better one...
Code: Select all
if (isset($resize))
{
if ($resize == "categories" || $resize == "products")
{
// An array of widths, keyed by target screen size
$widths = (
'475' => 237,
'768' => 384,
'1920' => 451,
);
}
elseif ($resize == "wide")
{
// An array of widths, keyed by target screen size
$widths = (
'475' => 237,
'768' => 384,
'1920' => 950,
);
}
elseif ($resize == "desktopslide")
{
// An array of widths, keyed by target screen size
$widths = (
'475' => 475,
'768' => 768,
'1920' => 1920,
);
}
}[text]Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in C:\xampp\phpMyAdmin\sote-wide\includes\a_page.inc on line 538[/text]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Image Resizing Script required - a better one...
For assigning values to array keys? Absolutely you can.simonmlewis wrote:Also it looks like if I change the [] fpr (), I cannot use =>.............. ?
5.4+
Code: Select all
// Returns an array of widths, keyed by target screen size
function getWidths($resize_option)
{
switch($resize_option) {
case 'categories':
case 'products':
case 'stockbanners':
$widths = [
'475' => 237,
'768' => 384,
'1920' => 451,
];
break;
case 'wide':
$widths = [
'475' => 237,
'768' => 384,
'1920' => 950,
];
break;
case 'desktopslide':
$widths = [
'475' => 475,
'768' => 768,
'1920' => 1920,
];
break;
default:
$widths = [];
break;
}
return $widths;
}Code: Select all
// Returns an array of widths, keyed by target screen size
function getWidths($resize_option)
{
switch($resize_option) {
case 'categories':
case 'products':
case 'stockbanners':
$widths = array(
'475' => 237,
'768' => 384,
'1920' => 451,
);
break;
case 'wide':
$widths = array(
'475' => 237,
'768' => 384,
'1920' => 950,
);
break;
case 'desktopslide':
$widths = array(
'475' => 475,
'768' => 768,
'1920' => 1920,
);
break;
default:
$widths = array();
break;
}
return $widths;
}-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Image Resizing Script required - a better one...
Ok. So the initial errors have gone, but now it is reporting the json files are missing from the "require once" folder.
I'm asking them if they should be installing it for me, as something is missing!
Or maybe I should do a require once to the core location of it.
I'm asking them if they should be installing it for me, as something is missing!
Or maybe I should do a require once to the core location of it.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Image Resizing Script required - a better one...
What json files? What's the error? Only json file I'm aware of is composer.json, which should be part of your deploy.simonmlewis wrote:Ok. So the initial errors have gone, but now it is reporting the json files are missing from the "require once" folder.
I'm asking them if they should be installing it for me, as something is missing!
Or maybe I should do a require once to the core location of it.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Image Resizing Script required - a better one...
What about in the function, as it doesn't like this, and it is probably because of $widths[], but it has return $widths at the end.
Can I just remove $widths =[]; ??
Code: Select all
// Returns an array of widths, keyed by target screen size
function getWidths($resize_option)
{
switch($resize_option) {
case 'categories':
case 'products':
case 'stockbanners':
$widths = (
'475' => 237,
'768' => 384,
'1920' => 451,
);
break;
case 'wide':
$widths = (
'475' => 237,
'768' => 384,
'1920' => 950,
);
break;
case 'desktopslide':
$widths = (
'475' => 475,
'768' => 768,
'1920' => 1920,
);
break;
case 'thumbnails':
$widths = (
'475' => 237,
'768' => 384,
'1920' => 451,
'2520' => 600,
);
break;
default:
$widths = [];
break;
}
return $widths;
}Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Image Resizing Script required - a better one...
Oh. Actually there are no json files in vendor, but since 'vendor' is in the require code, I Assume it should be in the live server too.Celauran wrote:What json files? What's the error? Only json file I'm aware of is composer.json, which should be part of your deploy.simonmlewis wrote:Ok. So the initial errors have gone, but now it is reporting the json files are missing from the "require once" folder.
I'm asking them if they should be installing it for me, as something is missing!
Or maybe I should do a require once to the core location of it.
I can see composer.json in my root. So if I manually upload that to the root of our beta site, do you think it would "find" where the files were installed on the server??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Image Resizing Script required - a better one...
Look at my example above. You can't just use (), you need to use the old array syntax, array().simonmlewis wrote:What about in the function, as it doesn't like this, and it is probably because of $widths[], but it has return $widths at the end.
Can I just remove $widths =[]; ??Code: Select all
// Returns an array of widths, keyed by target screen size function getWidths($resize_option) { switch($resize_option) { case 'categories': case 'products': case 'stockbanners': $widths = ( '475' => 237, '768' => 384, '1920' => 451, ); break; case 'wide': $widths = ( '475' => 237, '768' => 384, '1920' => 950, ); break; case 'desktopslide': $widths = ( '475' => 475, '768' => 768, '1920' => 1920, ); break; case 'thumbnails': $widths = ( '475' => 237, '768' => 384, '1920' => 451, '2520' => 600, ); break; default: $widths = []; break; } return $widths; }
Re: Image Resizing Script required - a better one...
No. Ideally you upload your composer.json and composer.lock files and then runsimonmlewis wrote:Oh. Actually there are no json files in vendor, but since 'vendor' is in the require code, I Assume it should be in the live server too.Celauran wrote:What json files? What's the error? Only json file I'm aware of is composer.json, which should be part of your deploy.simonmlewis wrote:Ok. So the initial errors have gone, but now it is reporting the json files are missing from the "require once" folder.
I'm asking them if they should be installing it for me, as something is missing!
Or maybe I should do a require once to the core location of it.
I can see composer.json in my root. So if I manually upload that to the root of our beta site, do you think it would "find" where the files were installed on the server??
composer install on the server. If that doesn't work, say because you don't have shell access on the server, then you'd need to upload your vendor directory as well.-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Image Resizing Script required - a better one...
I've uploaded the vendor files.
IT still has issues, most likely because of PHP versions and the scripts.
It now doesn't like this:
[text] mod_fcgid: stderr: PHP Warning: array_map(): Argument #2 should be an array in /var/www/vhosts/site.co.uk/subdomains/sand.site.co.uk/httpdocs/includes/a_page.inc on line 518, referer: http://sand.site.co.uk/a_page[/text]
IT still has issues, most likely because of PHP versions and the scripts.
It now doesn't like this:
Code: Select all
array_map('unlink', glob("images/pages/$new_filename*.$new_ext"));Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Image Resizing Script required - a better one...
Also within the function, do you mean the $widths should be like this?
Or...
[syntax]
default:
break;
}
return $widths();
}[/syntax]
Code: Select all
// Returns an array of widths, keyed by target screen size
function getWidths($resize_option)
{
switch($resize_option) {
case 'categories':
case 'products':
case 'stockbanners':
$widths = (
'475' => 237,
'768' => 384,
'1920' => 451,
);
break;
case 'wide':
$widths = (
'475' => 237,
'768' => 384,
'1920' => 950,
);
break;
case 'desktopslide':
$widths = (
'475' => 475,
'768' => 768,
'1920' => 1920,
);
break;
case 'thumbnails':
$widths = (
'475' => 237,
'768' => 384,
'1920' => 451,
'2520' => 600,
);
break;
default:
$widths = ();
break;
}
return $widths;
}[syntax]
default:
break;
}
return $widths();
}[/syntax]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Image Resizing Script required - a better one...
http://php.net/manual/en/function.glob.phpsimonmlewis wrote:It now doesn't like this:[text] mod_fcgid: stderr: PHP Warning: array_map(): Argument #2 should be an array in /var/www/vhosts/site.co.uk/subdomains/sand.site.co.uk/httpdocs/includes/a_page.inc on line 518, referer: http://sand.site.co.uk/a_page[/text]Code: Select all
array_map('unlink', glob("images/pages/$new_filename*.$new_ext"));
glob returns an empty array if it doesn't find anything, returns false on error. The error message above suggests the latter is happening. Pull that out into its own variable and inspect what's going on.
Re: Image Resizing Script required - a better one...
No, see my post here: viewtopic.php?f=1&t=143432&p=707696#p707687simonmlewis wrote:Also within the function, do you mean the $widths should be like this?
Or...Code: Select all
// Returns an array of widths, keyed by target screen size function getWidths($resize_option) { switch($resize_option) { case 'categories': case 'products': case 'stockbanners': $widths = ( '475' => 237, '768' => 384, '1920' => 451, ); break; case 'wide': $widths = ( '475' => 237, '768' => 384, '1920' => 950, ); break; case 'desktopslide': $widths = ( '475' => 475, '768' => 768, '1920' => 1920, ); break; case 'thumbnails': $widths = ( '475' => 237, '768' => 384, '1920' => 451, '2520' => 600, ); break; default: $widths = (); break; } return $widths; }
[syntax]
default:
break;
}
return $widths();
}[/syntax]
You need the array keyword in there.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Image Resizing Script required - a better one...
I understand. It's basically throw a fit because the image I want to delete, is not there.
So I am trying to upload an image, hoping it will create the other three as well.
It's now not upload an image.
It does add a row in the database.
It doesn't show anything in the error logs.
And no error is showing on screen.
In my upload script I have a small animation at the top "image uploading, one moment", then it returns to the admin screen.
It's not getting past that, presumably because it's getting blocked within the upload code.
I was hoping to see an error in the logs for not being able to find composer. But I have a feeling, a nagging feeling it's finding the files, but the files cannot locate the composer "engine" installed on the server.
So I am trying to upload an image, hoping it will create the other three as well.
It's now not upload an image.
It does add a row in the database.
It doesn't show anything in the error logs.
And no error is showing on screen.
In my upload script I have a small animation at the top "image uploading, one moment", then it returns to the admin screen.
It's not getting past that, presumably because it's getting blocked within the upload code.
I was hoping to see an error in the logs for not being able to find composer. But I have a feeling, a nagging feeling it's finding the files, but the files cannot locate the composer "engine" installed on the server.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.