-
Notifications
You must be signed in to change notification settings - Fork 415
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
插入图片缩小了,如何做成链接点击放大? #870
Labels
Comments
1、那个 link: {
/** 生成的<a>标签追加target属性的默认值 空:在<a>标签里不会追加target属性, _blank:在<a>标签里追加target="_blank"属性 */
target: "_blank",
/** 生成的<a>标签追加rel属性的默认值 空:在<a>标签里不会追加rel属性, nofollow:在<a>标签里追加rel="nofollow:在"属性*/
rel: "",
},
autoLink: {
/** 生成的<a>标签追加target属性的默认值 空:在<a>标签里不会追加target属性, _blank:在<a>标签里追加target="_blank"属性 */
target: "_blank",
/** 生成的<a>标签追加rel属性的默认值 空:在<a>标签里不会追加rel属性, nofollow:在<a>标签里追加rel="nofollow:在"属性*/
rel: "",
/** 是否开启短链接 */
enableShortLink: true,
/** 短链接长度 */
shortLinkLength: 20,
} 2、图片的title属性有么?或者能通过回调函数啥的把title属性设置成文件名么?不然图片多了,哪个图对应哪个文件就不知道了,查漏补缺比较麻烦,对着html代码一个个数太累。实在不行只能addEventListener大法对click和window.onload事件进行魔改了。 |
自己搞定了,写了两个函数,放在哪里好呢?config里有无合适callback的地方? //替换图片为链接
let images = Array.from(document.getElementById('content').getElementsByTagName('img'));
images.forEach(function (img) {
var link = document.createElement("a");
link.href = img.src;
link.target = "_blank"
link.appendChild(img.cloneNode(true))
img.parentNode.replaceChild(link, img);
});
//鼠标悬停显示链接地址
document.getElementById('content').addEventListener('mouseover', function (event) {
if (event.target.tagName === 'IMG') {
event.target.setAttribute('title', event.target.src)
} else if (event.target.tagName === 'A') {
event.target.setAttribute('target', '_blank')
event.target.setAttribute('title', event.target.href)
}
}) |
嗯嗯,这里的预览组件用的是这个:https://fengyuanchen.github.io/viewerjs/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1、插入的图片默认是60%大小看不清楚,能否变成链接形式,点击之后新开窗口打开100%大小的图?如何实现?
2、能否给插入的图片、音频文件加上alt、title等属性,方便鼠标悬停时展示文件名等描述信息?
3、插入file现在渲染出来只是一个超链接,可以在前面加个附件图标方便和普通链接区分
The text was updated successfully, but these errors were encountered: