Auto size images using Percent
-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
Auto size images using Percent
Hi all;
Previously in old oscommerce we were able to auto size images in browser using percentage;
But when I try add a percent value to the width in phoenix it comes up as a blank against the width parameter.
Is there something I need to define somewhere else too for it to work?
For Example :
$cm_i_slider_output .= new Image('images/' . $a['a_image'],[],htmlspecialchars(STORE_NAME), '100%', '100%');
This does not output the width and height as percentage.
Help shall be deeply appreciated;
Thank you in advance ;
Very Warm Regds./
radhavallabh
Previously in old oscommerce we were able to auto size images in browser using percentage;
But when I try add a percent value to the width in phoenix it comes up as a blank against the width parameter.
Is there something I need to define somewhere else too for it to work?
For Example :
$cm_i_slider_output .= new Image('images/' . $a['a_image'],[],htmlspecialchars(STORE_NAME), '100%', '100%');
This does not output the width and height as percentage.
Help shall be deeply appreciated;
Thank you in advance ;
Very Warm Regds./
radhavallabh
-
14Steve14
- Senior Contributor
- Posts: 922
- Joined: Fri Oct 25, 2019 7:01 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 17 times
- Been thanked: 103 times
Re: Auto size images using Percent
@radhavallabh What versions are you comparing. What ids your old version and what is your new version. Difficult for people to help without the basic information.
-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
Re: Auto size images using Percent
Hi;
Sorry for any confusion;
In comparison of oscommerce Frozen and Phoenix 1.0.8.21.
In oscommerce it was easy to define the width and height of the image in % format; But in phoenix the % seems to vanish from the width and height, it is regarded as pixels once i upload the code.
Thank you in advance;
Very Warm Regds./
radhavallabh
-
beerbee
- Member
- Posts: 48
- Joined: Mon Oct 26, 2020 4:56 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 5 times
Re: Auto size images using Percent
Hi,
what happens if you try it with using parameters?
Kind regards
Christoph
what happens if you try it with using parameters?
Code: Select all
new Image('images/' . $a['a_image'],['alt' => htmlspecialchars(STORE_NAME), 'width' => '100%', 'height' => '100%']);Christoph
- burt
- Core Team
- Posts: 4551
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Auto size images using Percent
There is no reason to set something 100%.
It is that by default, which is how "responsive" works...
Explain more clearly what you are trying to achieve ?
It is that by default, which is how "responsive" works...
Explain more clearly what you are trying to achieve ?
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
Re: Auto size images using Percent
Hi;beerbee wrote: ↑Wed May 01, 2024 8:54 am Hi,
what happens if you try it with using parameters?Kind regardsCode: Select all
new Image('images/' . $a['a_image'],['alt' => htmlspecialchars(STORE_NAME), 'width' => '100%', 'height' => '100%']);
Christoph
Extremely sorry for delayed reply,
It changes to 100 value (i.e. 100px) instead of the percentage as per checking in the browser console;
Regds./
radhavallabh
-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
Re: Auto size images using Percent
Hi;
Extremely sorry for delayed response;
Actually I do not want to set it at 100% only;
Need to set a image at 50% of a div width, which would hence take responsive sizing as per the div depending on its size in the viewport it is viewed in.
So I wanted to use percentage at some places.
Thank you for your help in advance;
Very Warm Regds./
radhavallabh
-
14Steve14
- Senior Contributor
- Posts: 922
- Joined: Fri Oct 25, 2019 7:01 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 17 times
- Been thanked: 103 times
Re: Auto size images using Percent
I dont know much about bootstrap and coding but wouldn't the size of the div be changed rather than the image as the image would change depending on the size of the div it is in. I thought that is what responsiveness was all about. Again, it depends on what you are trying to do.radhavallabh wrote: ↑Fri May 17, 2024 10:17 am
Need to set a image at 50% of a div width, which would hence take responsive sizing as per the div depending on its size in the viewport it is viewed in.
radhavallabh
All detailed here https://getbootstrap.com/docs/5.3/layout/grid/ plus so much more
-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
Re: Auto size images using Percent
Hi;14Steve14 wrote: ↑Fri May 17, 2024 10:31 amI dont know much about bootstrap and coding but wouldn't the size of the div be changed rather than the image as the image would change depending on the size of the div it is in. I thought that is what responsiveness was all about. Again, it depends on what you are trying to do.radhavallabh wrote: ↑Fri May 17, 2024 10:17 am
Need to set a image at 50% of a div width, which would hence take responsive sizing as per the div depending on its size in the viewport it is viewed in.
radhavallabh
All detailed here https://getbootstrap.com/docs/5.3/layout/grid/ plus so much more
I alreqady know that image becomes responsive to div, but it still shows the original pixel width, height size of it in browser console.
I want that the size of image appears in browser console in pixels-- as per the percentage of the image defined in php.
Regds./
radhavallabh
- burt
- Core Team
- Posts: 4551
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Auto size images using Percent
Steve is correct. The sizing would usually be done on the div (note this is NOT useable code);
Now your image is in the 50% div that is half of the larger div.
Alternatively you can use width utility;
https://getbootstrap.com/docs/4.6/utili ... the-parent
Code: Select all
<div 100%>
<div 50%>
<img>
</div>
</div>Alternatively you can use width utility;
https://getbootstrap.com/docs/4.6/utili ... the-parent
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.