News:

Support the VirtueMart project and become a member

Main Menu

thumbnail size attributes in html output

Started by Csabesz, July 16, 2014, 10:08:14 AM

Previous topic - Next topic

Csabesz

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.

GJC Web Design

Sorry - totally unclear to me what you mean - and no versions etc
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Csabesz

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.

GJC Web Design

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)
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Csabesz

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.

GJC Web Design

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...
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Csabesz

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.

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Csabesz

Yes but you don`t know my client :))))
He is very demanding.

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Csabesz

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 :)

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Csabesz

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?

GJC Web Design

probably need absolute path - check joomla docs how to get that
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Csabesz

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 :((