PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Mar 23, 2017 9:06 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 539 posts ]  Go to page Previous  1 ... 32, 33, 34, 35, 36
Author Message
PostPosted: Wed Mar 15, 2017 8:37 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6187
Location: Montreal, Canada
simonmlewis wrote:
I See. So outside of that loop, I then add this into the srcset, if the resize_type is one of the three.

Syntax: [ Download ] [ Hide ]
$basename = pathinfo($filename, PATHINFO_FILENAME);
$extension = pathinfo($filename, PATHINFO_EXTENSION);

foreach ($widths as $size => $width) {
$fullname = $basename . '_' . $size . '.' . $extension;
if (file_exists($thumbnail_directory . DIRECTORY_SEPARATOR . $fullname)) {
$srcset[] = "{$images_path}/{$fullname} {$size}w";
} else {
resizeSingleImage($filename, $size, $width, $resize_type);
$srcset[] = "{$images_path}/{$fullname} {$size}w";
}
}

if ($resize_type == "categories" || $resize_type == "products" || $resize_type == "wide")
  {
    $srcset[] = "{$images_path}/{$filename} {$size}w";
  }
}

return implode(', ', $srcset);
}

Better. Where is $size coming from in this instance?

simonmlewis wrote:
But how do I tell it this is for 2560 ?

What's 2560? You keep mentioning this number but you aren't resizing an image to that size. You've got a list of the desired smaller sizes. You just want to add the size of the original image to the srcset list. So again, what's this 2560?

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:41 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4138
Location: United Kingdom
$size is within that overall function. Is that not putting the $size into the srcset code?
2560 is the resolution, like we have 475, 768 and 1920. Do I need to add it into the list at the top? Tho I thought that was about fetching the sizing information to tell it the pixel width to use.

As you say, we are not resizing this image, but we do need to tell it /images/pages/123.jpg 2560w.... don't we?

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:42 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4138
Location: United Kingdom
I think I need to add it to th top case list. But each of those has a number assigned to it, to resize the image. We aren't resizing.

This is why I am a bit confused.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:43 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6187
Location: Montreal, Canada
simonmlewis wrote:
As you say, we are not resizing this image, but we do need to tell it /images/pages/123.jpg 2560w.... don't we?

Would it not make more sense to tell it the actual width of the image?

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:44 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6187
Location: Montreal, Canada
simonmlewis wrote:
I think I need to add it to th top case list. But each of those has a number assigned to it, to resize the image. We aren't resizing.

This is why I am a bit confused.

You don't want to put it in getWidths. That's for resizing. As you say, we aren't resizing this. Doesn't belong there.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:45 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4138
Location: United Kingdom
it would vary. But I think that code is in that script, asking what it is.. is it not?
Why is that important?

And no, didn't think it should go in there. Just wondered since that gathers sizing info.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:47 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6187
Location: Montreal, Canada
simonmlewis wrote:
it would vary. But I think that code is in that script, asking what it is.. is it not?
Why is that important?

It's not clear what you're replying to here. What would vary? Why is what important?

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:50 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4138
Location: United Kingdom
Celauran wrote:
simonmlewis wrote:
As you say, we are not resizing this image, but we do need to tell it /images/pages/123.jpg 2560w.... don't we?

Would it not make more sense to tell it the actual width of the image?

Why would putting in the actual size be right? why not put in 2560?

I know something has to go on the end there where $size is. Does it not?
Are you suggesting that rather than put in $size, we put in $currentimagesize ?

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:52 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6187
Location: Montreal, Canada
simonmlewis wrote:
Celauran wrote:
simonmlewis wrote:
As you say, we are not resizing this image, but we do need to tell it /images/pages/123.jpg 2560w.... don't we?

Would it not make more sense to tell it the actual width of the image?

Why would putting in the actual size be right? why not put in 2560?

That was my understanding of how srcset is meant to work (link). Give it a list of images and their widths. You can hardcode 2560 if you prefer.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:54 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4138
Location: United Kingdom
The only reason I am saying 2560, is because the others are labelled correctly. If I had whatever the current size is, it would make less sense. So I think I am very close. Do I just hardcode in:
Syntax: [ Download ] [ Hide ]
if ($resize_type == "categories" || $resize_type == "products" || $resize_type == "wide")
  {
    $srcset[] = "{$images_path}/{$filename} 2560w";
  }
}

?

So that line goes on the end of the array, for those three images?

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:56 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6187
Location: Montreal, Canada
simonmlewis wrote:
The only reason I am saying 2560, is because the others are labelled correctly. If I had whatever the current size is, it would make less sense. So I think I am very close. Do I just hardcode in:
Syntax: [ Download ] [ Hide ]
if ($resize_type == "categories" || $resize_type == "products" || $resize_type == "wide")
  {
    $srcset[] = "{$images_path}/{$filename} 2560w";
  }
}

?

So that line goes on the end of the array, for those three images?

That would accomplish what you're trying to achieve, yes. Still not sure that you aren't meant to put in the actual width of the image, but that's neither here nor there.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 8:58 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4138
Location: United Kingdom
We aren't putting in the size of ANY of the actual images, unless we are resizing them to a specific size. I think in the source code of the rendered page, it would make way more sense to see 475, 768, 1920, 2560. Rather than, 576, 768, 1920, 650/750 etc. As that would probably confuse. It would tell us the size of it, but that area is to tell the browser (and me) what image is being used, and where.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 9:01 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6187
Location: Montreal, Canada
As I've stated, front end isn't my strong suit, so I'm not going to argue with how it's meant to work or not work. What I can do is try to help you accomplish the goal you've set out for yourself. If you would like to have 2560w for every full sized image, then hardcoding that seems to me to be the simplest solution.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 9:03 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4138
Location: United Kingdom
Yeah - since it will be used ONLY for that size of screen. Well, that and above one day!

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 539 posts ]  Go to page Previous  1 ... 32, 33, 34, 35, 36

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group