//计算视觉优先的图片宽高

functionwxAutoImageCal(originalWidth, originalHeight, that, bindName, temImage) {var arr =temImage.attr.style;var widthIndex = arr.indexOf("width:");

console.log(widthIndex);var widthValue = '';if (widthIndex != -1) {//widthValue = arr[widthIndex + 1];

console.log(arr);var trr = arr.split(";");///sophie

for(let i=0;i

widthValue=trr[i].split(":")[1];

}

}//console.log(trr);

console.log(widthValue);

}var percentageIndex = widthValue.search("%");var pixelIndex = widthValue.search("px");var percentageWidthValue = '';var pixelWidthValue = '';var pixelHeightValue = '';

console.log(percentageIndex);

console.log(pixelIndex);/**

* 获取width的百分比数值

* 因为widthValue是带有%和;的,例如宽度为50%,那么widthValue的数据格式为widthValue == "50%;",

* 因此多出来后面两个字符'%;',所以要去除后面两位*/

if ((percentageIndex > 0) && (widthValue.length == percentageIndex + 2)) {

percentageWidthValue= widthValue.slice(0, -2);

}/**

* 获取width的px数值

* 因为widthValue是带有px和;的,例如宽度为50px,那么widthValue的数据格式为widthValue == "50px;",

* 因此多出来后面三个字符'px;',所以要去除后面三位,

* 而当width为px显示时,height和width是成对出现的*/

if ((pixelIndex > 0) && (widthValue.length == pixelIndex + 2)) {

pixelWidthValue= widthValue.slice(0, -2);var heightIndex = arr.indexOf("height:");var heightValue = '';if (heightIndex != -1) {//heightValue = arr[heightIndex + 1];

console.log(arr);var hrr = arr.split(";");///sophie

for (let i = 0; i < hrr.length; ++i) {if (hrr[i].indexOf("height") != -1) {

heightValue= hrr[i].split(":")[1];

}

}

console.log(heightValue);

}var pixelHeightIndex = heightValue.search("px");if ((pixelHeightIndex > 0) && (heightValue.length == pixelHeightIndex + 2)) {

pixelHeightValue= heightValue.slice(0, -2);

}

}

console.log(pixelHeightValue);//获取图片的原始长宽

var windowWidth = 0, windowHeight = 0;var autoWidth = 0, autoHeight = 0;var results ={};var padding =that.data[bindName].view.imagePadding;

windowWidth= realWindowWidth - 2 *padding;

windowHeight=realWindowHeight;/**

* 1、如果图片的宽度style是百分比的参数形式,那么图片在微信中展示的宽度就定义为 手机屏幕宽度*宽度百分比;

* 2、如果图片的宽度style是px的参数形式,并且该宽度小于屏幕宽度,那么图片在微信中展示的宽、高就定义为 style所设置的宽、高;

* 3、此外,则按原插件逻辑进行图片大小定义,在图片width大于手机屏幕width时等比例缩放至屏幕大小,

* 未大于手机屏幕width时则按图片原尺寸显示*/

if(percentageWidthValue) {

autoWidth= (windowWidth * percentageWidthValue) / 100;

autoHeight= (autoWidth * originalHeight) /originalWidth;

results.imageWidth=autoWidth;

results.imageheight=autoHeight;

}else if (pixelWidthValue && pixelHeightValue && (pixelWidthValue <=windowWidth)) {

results.imageWidth=pixelWidthValue;

results.imageheight=pixelHeightValue;

}else{//判断按照那种方式进行缩放

//console.log("windowWidth" + windowWidth);

if (originalWidth > windowWidth) {//在图片width大于手机屏幕width时候

autoWidth =windowWidth;//console.log("autoWidth" + autoWidth);

autoHeight = (autoWidth * originalHeight) /originalWidth;//console.log("autoHeight" + autoHeight);

results.imageWidth =autoWidth;

results.imageheight=autoHeight;

}else {//否则展示原来的数据

results.imageWidth =originalWidth;

results.imageheight=originalHeight;

}

}returnresults;

}

linux 微信不能发图片大小,解决微信插件wxparse图片大小不能改变的问题相关推荐

  1. python 微信聊天机器人_python操作微信自动发消息的实现(微信聊天机器人)

    前言 最近在学习python,发现一个微信自动发消息的小demo感觉很有意思,试了一下,不成功,因为demo中用的是itchat这个库来操作微信,而这个库是通过微信网页版来操作微信的,现在微信网页版已 ...

  2. python微信自动发消息_python操作微信自动发消息的实现(微信聊天机器人)

    前言 最近在学习python,发现一个微信自动发消息的小demo感觉很有意思,试了一下,不成功,因为demo中用的是itchat这个库来操作微信,而这个库是通过微信网页版来操作微信的,现在微信网页版已 ...

  3. 设置背景图片,解决手机上背景图片高度适应问题

    设置背景图片,解决手机上背景图片高度适应问题 第一种方法:直接对图片进行设置,代码如下 <img src="url" class="PhoneBack"& ...

  4. php解决微信防盗链,PHP如何解决微信文章图片防盗链

    微信对外提供了API接口,让我们可以通过授权的方式获取到自己公众号里面的文章 或者你也可以通过爬虫去抓取微信的文章 但是微信的图片默认是不允许外部调用的 解决微信文章图片防盗链 function ac ...

  5. php 微信防盗链,PHP如何解决微信文章图片防盗链

    微信对外提供了API接口,让我们可以通过授权的方式获取到自己公众号里面的文章 或者你也可以通过爬虫去抓取微信的文章 但是微信的图片默认是不允许外部调用的 解决微信文章图片防盗链 function ac ...

  6. ubuntu20 从wine安装到微信3的使用(解决微信乱码、无法输入)

    ubuntu微信安装,综合了别人的方法,把我遇到的问题和解决方法贴上,以下进行了实测有效. 1.在ubuntu20上安装wine5或wine6 使用deepin-wine版的微信有点旧了.所以打算自己 ...

  7. html5微信视频无法播放视频教程,解决微信h5页面视频播放问题实例

    解决微信h5页面视频播放问题实例 content="width=device-width,initial-scale=1, maximum-scale=1.0, minimum-scale= ...

  8. python微信自动发消息_Python使用微信itchat接口实现查看自己微信的信息功能详解...

    Python使用微信itchat接口实现查看自己微信的信息功能详解 发布时间:2020-09-09 04:20:11 来源:脚本之家 阅读:134 本文实例讲述了Python使用微信itchat接口实 ...

  9. 微信小程序不支持打开非业务域名_一行代码网站封装微信小程序,并解决微信小程序不支持打开非业务域名https://,请重新配置的问题!...

    一行代码封装微信小程序 利用「」一行代码原封不动的把你现有博客或者网站封装成小程序. 第一步 注册微信小程序账号并登陆,点击菜单栏 "开发" 中的"开发设置", ...

  10. 微信智慧支付日系统服务器崩溃,微信支付大面积出现故障 微信支付系统繁忙怎么解决 微信支付崩溃原因是什么...

    10月29日晚间,微信支付突然大面积出现故障,支付时显示错误,商家扫码枪显示失败,美团外卖.京东商城.滴滴出行等支持微信支付的软件中,均显示暂不能使用微信支付.如果直接用微信支付扫码付款,也会出现&q ...

最新文章

  1. bd2和mysql语法区别,经验:在MySQL数据库中,这4种方式可以避免重复的插入数据!...
  2. Java机器学习库ML之十模型选择准则AIC和BIC
  3. 【spring boot】新建项目,实现HelloWorld
  4. 33行代码AC——例题6-5 移动盒子(Boxes in a Line, UVa 12657)——解题报告
  5. blender 3d打印_使用Blender和Python 3D打印连衣裙
  6. 《how to write and publish a scientific paper》 Chapter 4
  7. 2021-08-27小白笔记3
  8. [02/Dec/2019:12:59:10 +0800]之日期转换
  9. lotus version 0.3.0+git1bfa2311 安装 interopnet
  10. POS标记——HMM模型
  11. 中国日期转化标准日期(YYYY-MM-dd)
  12. 第14期《成长之路》2017年8月刊
  13. Codeforces 148D. Bag of mice(概率dp)
  14. 项目管理相关认证简要介绍(1)- 体系
  15. python程序员兼职平台-用Python拓展副业的几种方式
  16. Cisco交换机配合NPS执行802.1X有线准入
  17. PB中小写金额转换成大写金额(发票类型)
  18. 情感隐喻(Affective Metaphor)
  19. STATA 常用模型与命令
  20. R语言可视化:使用ggplot2绘制人口金字塔

热门文章

  1. 滴滴快车奖励政策,高峰奖励,翻倍奖励,按成交率,指派单数分级(3月19日)...
  2. 【BLE】CC2541之SNV
  3. android 统计app使用时间,android开发之app在线时长统计sdk开发
  4. Kali2021修改更新源
  5. wps office2019PC版和Mac版_【MAC】Apple专业定制版视频编辑软件
  6. 波特率的解析及转换为字节传输速率
  7. Gluster常见故障处理和HOWTO资源
  8. 关于虚拟机无法创建目录的问题
  9. pay 和 put的用法
  10. 银河系中央超大黑洞可能是个虫洞 其连接着两个不同的时空。