Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

微信分享的默认图片 #3

Open
tjuking opened this issue Sep 11, 2015 · 3 comments
Open

微信分享的默认图片 #3

tjuking opened this issue Sep 11, 2015 · 3 comments

Comments

@tjuking
Copy link
Owner

tjuking commented Sep 11, 2015

在微信中分享页面时,如何控制展现的图片?

第一种方法当然是使用微信的JSSDK,如果你不想引入一个Javascript脚本也不想这么麻烦的话,那么可以考虑下面的方法。

使用这种方法需要满足以下三个条件:

  • 图片尺寸大于300*300
  • 图片不能设置为display: none
  • 在满足上述条件的图片中选择最早解析的图片

如果你也不想让这个图片在网页中正常展示的话,可以设置父容器隐藏(也可以设置图片的宽高为0),例如:

<div style="display:none">
    <img src="http://www.x.com/share.jpg"/>
</div>

如果担心300*300尺寸的图片会影响网页的性能,可以将图片设置为JPG格式,通过有损压缩可以将图片控制到几kb。

@ylb1992
Copy link

ylb1992 commented May 18, 2017

现在第二种方法已经不能生效了,貌似只能用JSSDK了

@tjuking
Copy link
Owner Author

tjuking commented Jun 28, 2017

@ylb1992 应该是微信又调整规则了...

@ylb1992
Copy link

ylb1992 commented Jul 7, 2017

之前项目里偷懒的做法都重做了,哈哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants