linux 微信不能发图片大小,解决微信插件wxparse图片大小不能改变的问题
//计算视觉优先的图片宽高
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图片大小不能改变的问题相关推荐
- python 微信聊天机器人_python操作微信自动发消息的实现(微信聊天机器人)
前言 最近在学习python,发现一个微信自动发消息的小demo感觉很有意思,试了一下,不成功,因为demo中用的是itchat这个库来操作微信,而这个库是通过微信网页版来操作微信的,现在微信网页版已 ...
- python微信自动发消息_python操作微信自动发消息的实现(微信聊天机器人)
前言 最近在学习python,发现一个微信自动发消息的小demo感觉很有意思,试了一下,不成功,因为demo中用的是itchat这个库来操作微信,而这个库是通过微信网页版来操作微信的,现在微信网页版已 ...
- 设置背景图片,解决手机上背景图片高度适应问题
设置背景图片,解决手机上背景图片高度适应问题 第一种方法:直接对图片进行设置,代码如下 <img src="url" class="PhoneBack"& ...
- php解决微信防盗链,PHP如何解决微信文章图片防盗链
微信对外提供了API接口,让我们可以通过授权的方式获取到自己公众号里面的文章 或者你也可以通过爬虫去抓取微信的文章 但是微信的图片默认是不允许外部调用的 解决微信文章图片防盗链 function ac ...
- php 微信防盗链,PHP如何解决微信文章图片防盗链
微信对外提供了API接口,让我们可以通过授权的方式获取到自己公众号里面的文章 或者你也可以通过爬虫去抓取微信的文章 但是微信的图片默认是不允许外部调用的 解决微信文章图片防盗链 function ac ...
- ubuntu20 从wine安装到微信3的使用(解决微信乱码、无法输入)
ubuntu微信安装,综合了别人的方法,把我遇到的问题和解决方法贴上,以下进行了实测有效. 1.在ubuntu20上安装wine5或wine6 使用deepin-wine版的微信有点旧了.所以打算自己 ...
- html5微信视频无法播放视频教程,解决微信h5页面视频播放问题实例
解决微信h5页面视频播放问题实例 content="width=device-width,initial-scale=1, maximum-scale=1.0, minimum-scale= ...
- python微信自动发消息_Python使用微信itchat接口实现查看自己微信的信息功能详解...
Python使用微信itchat接口实现查看自己微信的信息功能详解 发布时间:2020-09-09 04:20:11 来源:脚本之家 阅读:134 本文实例讲述了Python使用微信itchat接口实 ...
- 微信小程序不支持打开非业务域名_一行代码网站封装微信小程序,并解决微信小程序不支持打开非业务域名https://,请重新配置的问题!...
一行代码封装微信小程序 利用「」一行代码原封不动的把你现有博客或者网站封装成小程序. 第一步 注册微信小程序账号并登陆,点击菜单栏 "开发" 中的"开发设置", ...
- 微信智慧支付日系统服务器崩溃,微信支付大面积出现故障 微信支付系统繁忙怎么解决 微信支付崩溃原因是什么...
10月29日晚间,微信支付突然大面积出现故障,支付时显示错误,商家扫码枪显示失败,美团外卖.京东商城.滴滴出行等支持微信支付的软件中,均显示暂不能使用微信支付.如果直接用微信支付扫码付款,也会出现&q ...
最新文章
- bd2和mysql语法区别,经验:在MySQL数据库中,这4种方式可以避免重复的插入数据!...
- Java机器学习库ML之十模型选择准则AIC和BIC
- 【spring boot】新建项目,实现HelloWorld
- 33行代码AC——例题6-5 移动盒子(Boxes in a Line, UVa 12657)——解题报告
- blender 3d打印_使用Blender和Python 3D打印连衣裙
- 《how to write and publish a scientific paper》 Chapter 4
- 2021-08-27小白笔记3
- [02/Dec/2019:12:59:10 +0800]之日期转换
- lotus version 0.3.0+git1bfa2311 安装 interopnet
- POS标记——HMM模型
- 中国日期转化标准日期(YYYY-MM-dd)
- 第14期《成长之路》2017年8月刊
- Codeforces 148D. Bag of mice(概率dp)
- 项目管理相关认证简要介绍(1)- 体系
- python程序员兼职平台-用Python拓展副业的几种方式
- Cisco交换机配合NPS执行802.1X有线准入
- PB中小写金额转换成大写金额(发票类型)
- 情感隐喻(Affective Metaphor)
- STATA 常用模型与命令
- R语言可视化:使用ggplot2绘制人口金字塔