Hi all,
I need to put thumbnail image sizes in html output on category page layout(for seo purposes), but the problem is I have different sizes of thumbnails,
is any possibility to get image dimension attributes and put them in html output?
Thanks all.
Sorry - totally unclear to me what you mean - and no versions etc
Hi,
sorry, virtuemart version is 2.0.26 but I think is not so important.
Let me show one example, now my html output for image is:
<a class="modal" href="http://www.cupe-medalii.ro/images/stories/virtuemart/product/figurine-plastic_fg_888.jpg" title="Figurine plastic FG 888">
<img class="browseProductImage" title="Figurine Sportive FG 888" alt="Figurine plastic FG 888" src="/images/stories/virtuemart/product/resized/figurine-plastic_fg_888_190x190.jpg">
</a>
what I need is to insert the height and width attributes, the above example should be:
<a class="modal" href="http://www.cupe-medalii.ro/images/stories/virtuemart/product/figurine-plastic_fg_888.jpg" title="Figurine plastic FG 888" width="126" height="190">
<img class="browseProductImage" title="Figurine Sportive FG 888" alt="Figurine plastic FG 888" src="/images/stories/virtuemart/product/resized/figurine-plastic_fg_888_190x190.jpg">
</a>
on the other images, I have 2 types of images, cause why I cant put manualy the values:
<a class="modal" href="http://www.cupe-medalii.ro/images/stories/virtuemart/product/cupe_sportive_cs_53.jpg" title="Cupe sportive CS 53" width="190" height="126">
<img class="browseProductImage" title="Cupe Sportive CS 53" alt="Cupe sportive CS 53" src="/images/stories/virtuemart/product/resized/cupe_sportive_cs_53_190x190.jpg">
</a>
somehow I should get the images real size and use in html output.
if your using the standard displayMediaThumb() function you can pass the dimensions
displayMediaThumb($imageArgs='',$lightbox=true,$effect="class='modal' rel='group'",$return = true,$withDescr = false,$absUrl = false, $width=0,$height=0)
The line above I have on default.php for category or products display:
echo $product->images[0]->displayMediaThumb('class="browseProductImage" title="'.$product->product_name.'" ',true,'class="modal"')
I think is a query needed for displayable images dimensions and put in the line above the values.
I just showed you the possible attributes of the function displayMediaThumb
yes - if you want to feed it different sizes for every image I think it would be much easier just to push some cotten wool balls up a mountain in a storm with a pointy stick...
Is it not fairly obvious (and oh so much easier and more professional) to simply make your images the same size and ratio????????
Then you can put your new std. size in the function attribute...
Yes, it would be simpler but the client spent a lot of money for professional images and do not want to spend more for remake them on same sizes.
The site is in a good position in google for keywords but no for image search, I thought it would help for image search.
Thanks for your time.
But you can batch process 100's of images to a set size in moments with any decent graphics software - incl. adding background canvas to pad out if needed
Yes but you don`t know my client :))))
He is very demanding.
You have my sympathies - so your only other option is to use std php functions to find the height and width of the image and feed it into the thumbnail call
OK, I'll search for this solution.
If I get to solve this I`ll share here in case if needed by others.
Best regards :)
have a look at php function getimagesize($filename)
//getimagesize returns array
//
- = width in pixels
// [1] = height in pixels
// [2] = type
// [3] = img tag "width=xx height=xx" values
Hello again,
<?php /** @todo make image popup */
$myimage = $product->images[0]->displayMediaThumb;
$size = getimagesize($myimage);
echo $size; /*for test*/
echo $product->images[0]->displayMediaThumb('class="browseProductImage"'.$size[3].' title="'.$product->product_name.'" ',true,'class="modal"' );?>
returns empty values, where i`m wrong?
probably need absolute path - check joomla docs how to get that
Hello again, I was on vacation :)
the new code is:
<?php /** @todo make image popup */
$base=JURI::base();
$link=$base."images/stories/virtuemart/product/";
$myimage = $link.$product->images[0]->displayMediaThumb;
$size = getimagesize($myimage);
echo $size; /*for test*/
echo $product->images[0]->displayMediaThumb('class="browseProductImage"'.$size[3].' title="'.$product->product_name.'" ',true,'class="modal"' );?>
but nothing, the variable size is empty :((
you can't echo an array
use print 'Debug Line '.__LINE__.' $size <pre>'; print_r ($size); print "</pre><br />\n";
Hello,
now I get the following line but without sizes:
Debug Line 68 $size
and many thanks for your help!!!
come on - this is basic trouble shooting and dev - try a bit harder ..
so your $myimage isn't an image
I thought that not an image, I`m in trouble to find the way to the image.
do what everyone does - echo out your vars every step till you find the problem
use print 'Debug Line '.__LINE__.' $yourvar <pre>'; print_r ($yourvar); print "</pre><br />\n";
turn your error reporting full up to see the problems - this is development.....
php is a very logical step by step language