douhu1990 2012-08-07 19:24
浏览 475
已采纳

使用Woo Commerce更改图像大小

I have a customer whose products are the photographs he's taken. The store, then (using Woo Commerce) shows thumbnails of the images, and when you click you get the full size.

The problem is there is only one thumbnail size setting in the back end and its set for horizontal images - but some images are vertical.

http://itestwebpageshere.biz/product-category/carribean/

How can I adjust the vertical images independently. Ideas are welcome, even if you can't post a coded solution. I've been racking my brain for a while on this and can't seem to come up with anything easier than re-writing the way Woo Commerce deals with images to have a 'vertical' option.

  • 写回答

1条回答 默认 最新

  • doucheng4660 2012-08-08 23:15
    关注

    So here's what I came to:

    In the CSS, where the class for the product images was declared there was:

    width: 100%;
    

    I changed it to:

    max-width: 100%;
    

    Logic behind the fix:

    If the width is at 100% of the div element the images are in, the horizontal images are capped at a max with (220px in this case), but the vertical image is stretched to that width. Woocommerce automatically scales its height to match, causing the theme to break. If we switch the width to 'auto' then the images will sit at their natural width. This causes the theme to break again because now the horizontal images aren't capped at a certain width (and become too wide for the page).

    By declaring only max-width at 100% we do two things: We limit the width of the horizontal images to the size of the block element they're in (220px); We let the CSS sort out the min-width on its own. Because no width or min width is declared, they will be set to 'auto'.

    This allows the vertical image to sit at its natural width, but caps the horizontal images at the width of the box, thus keeping all of the images scaled and our layout clean and lined up.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao