News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Add class to product image

Started by DarthOlolo, September 14, 2017, 18:34:09 PM

Previous topic - Next topic

DarthOlolo

Good afternoon, faced with the following problem. I can not add a class for the product image in the product card.
As far as I understand, one of the files view \ productdetails \ tmpl \ default_images.php or default_images_additional.pxp is responsible for processing. But unfortunately nothing happens.
Tell me, please, how best to add a class for a product photo?

UPD.: Sorry for the small amount of information ...
Joomla Version - 3.7.4
VM version - 3.2.4
PHP version is 5.6.30 + dfsg-0 + deb8u1
VM Template - standard, which went by default
Link for example - https://test.dartharth.ru/katalog/plavayushchie-vodyanye-lilii/liliya-6

The problem is adding a css class for the product image that is inside the block with the class "vm-product-media-container"

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

GJC Web Design

why not target it with

.vm-product-media-container > img {

}

its the same thing
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

DarthOlolo

Quote from: GJC Web Design on September 14, 2017, 23:30:01 PM
why not target it with

.vm-product-media-container > img {

}

its the same thing

The fact is that a class is necessary for processing a photo by a plug-in that reacts only to a class of photos.

jenkinhill

For default VM templates  using  .main-image > img would be more specific.  Unless you use template overrides which us a different class already.

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

GJC Web Design

use a Js snippet to ad a class?

not tested

<script type="text/javascript">
   jQuery(document).ready(function($){
      $('.main-image > img').addClass('my_img_class');
   });
   jQuery.noConflict();
</script>
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

Spiros Petrakis

Hi,
for the main image open default_images.php and add the class attribute and name in the displayMediaFull function like this :

Before

echo $image->displayMediaFull("",true,"rel='vm-additional-images'");


After

echo $image->displayMediaFull("class='MyClassName'",true,"rel='vm-additional-images'");


the same way you can add a class to additional images.
Joomla templates and extensions development
https://www.yourgeek.gr