Skip to content

Commit

Permalink
preview-img 属性支持设置为 all 开启 base64 图片预览 #536
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-yufeng committed Apr 16, 2024
1 parent 7a0dc99 commit c92fc80
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/miniprogram/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ Component({

/**
* @description 是否允许图片被点击时自动预览
* @type {Boolean}
* @type {Boolean | String}
* @default true
*/
previewImg: {
type: Boolean,
type: null,
value: true
},

Expand Down
2 changes: 1 addition & 1 deletion src/miniprogram/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ Parser.prototype.onOpenTag = function (selfClose) {
node.webp = 'T'
}
// data url 图片如果没有设置 original-src 默认为不可预览的小图片
if (attrs.src.includes('data:') && !attrs['original-src']) {
if (attrs.src.includes('data:') && this.options.previewImg !== 'all' && !attrs['original-src']) {
attrs.ignore = 'T'
}
if (!attrs.ignore || node.webp || attrs.src.includes('cloud://')) {
Expand Down
2 changes: 1 addition & 1 deletion src/uni-app/components/mp-html/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ Parser.prototype.onOpenTag = function (selfClose) {
node.webp = 'T'
}
// data url 图片如果没有设置 original-src 默认为不可预览的小图片
if (attrs.src.includes('data:') && !attrs['original-src']) {
if (attrs.src.includes('data:') && this.options.previewImg !== 'all' && !attrs['original-src']) {
attrs.ignore = 'T'
}
if (!attrs.ignore || node.webp || attrs.src.includes('cloud://')) {
Expand Down

0 comments on commit c92fc80

Please sign in to comment.