VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Csabesz on July 16, 2014, 10:08:14 AM

Title: thumbnail size attributes in html output
Post by: Csabesz on July 16, 2014, 10:08:14 AM
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.
Title: Re: thumbnail size attributes in html output
Post by: GJC Web Design on July 17, 2014, 11:03:13 AM
Sorry - totally unclear to me what you mean - and no versions etc
Title: Re: thumbnail size attributes in html output
Post by: Csabesz on July 17, 2014, 11:26:59 AM
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.
Title: Re: thumbnail size attributes in html output
Post by: GJC Web Design on July 17, 2014, 15:07:54 PM
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)
Title: Re: thumbnail size attributes in html output
Post by: Csabesz on July 17, 2014, 15:22:52 PM
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.
Title: Re: thumbnail size attributes in html output
Post by: GJC Web Design on July 17, 2014, 17:32:50 PM
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...
Title: Re: thumbnail size attributes in html output
Post by: Csabesz on July 18, 2014, 08:28:24 AM
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.
Title: Re: thumbnail size attributes in html output
Post by: GJC Web Design on July 18, 2014, 09:49:41 AM
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
Title: Re: thumbnail size attributes in html output
Post by: Csabesz on July 18, 2014, 09:52:13 AM
Yes but you don`t know my client :))))
He is very demanding.
Title: Re: thumbnail size attributes in html output
Post by: GJC Web Design on July 18, 2014, 09:53:46 AM
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
Title: Re: thumbnail size attributes in html output
Post by: Csabesz on July 18, 2014, 10:02:38 AM
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 :)
Title: Re: thumbnail size attributes in html output
Post by: GJC Web Design on July 18, 2014, 10:37:28 AM
have a look at php function getimagesize($filename)

//getimagesize returns array
      //
Title: Re: thumbnail size attributes in html output
Post by: Csabesz on July 18, 2014, 11:13:22 AM
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?
Title: Re: thumbnail size attributes in html output
Post by: GJC Web Design on July 18, 2014, 12:31:11 PM
probably need absolute path - check joomla docs how to get that
Title: Re: thumbnail size attributes in html output
Post by: Csabesz on August 07, 2014, 14:11:07 PM
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 :((
Title: Re: thumbnail size attributes in html output
Post by: GJC Web Design on August 07, 2014, 14:15:42 PM
you can't echo an array

use print 'Debug Line '.__LINE__.' $size <pre>'; print_r ($size); print "</pre><br />\n";
Title: Re: thumbnail size attributes in html output
Post by: Csabesz on August 07, 2014, 14:25:30 PM
Hello,

now I get the following line but without sizes:

Debug Line 68 $size


and many thanks for your help!!!
Title: Re: thumbnail size attributes in html output
Post by: GJC Web Design on August 07, 2014, 15:09:57 PM
come on - this is basic trouble shooting and dev - try a bit harder ..

so your $myimage isn't an image
Title: Re: thumbnail size attributes in html output
Post by: Csabesz on August 07, 2014, 15:44:32 PM
I thought that not an image, I`m in trouble to find the way to the image.
Title: Re: thumbnail size attributes in html output
Post by: GJC Web Design on August 07, 2014, 16:54:21 PM
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