Lưu trữ Blog

Được tạo bởi Blogger.

Tự động thêm thẻ alt và title cho hình ảnh blogspot

Category: , Written by Unknown / 16:23
Chào các bạn tiếp tục series Tối ưu hóa blogspot - Tối ưu hóa blogger chuẩn seo blogspot - chuẩn seo blogger. Hôm nay mình sẽ chỉ cách cho các bạn Tự động thêm thẻ alt và title cho hình ảnh blogspot



Để thực hiện được điều này, việc bạn phải làm đơn giản chỉ là thêm 1 đoạn script vào template Blogspot.

Đăng nhập vào Blogspot, trong tab Template, chọn Edit Html.

Sau đó bạn tìm thẻ đóng </body> và thêm đoạn script dưới đây vào bên trên thẻ </body>:



<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'/>
<script type='text/javascript'>
$(document).ready(function() {$('img').each(function(){var $img = $(this);var filename = $img.attr('src')$img.attr('alt', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));});});</script>
<script type='text/javascript'>
$(document).ready(function() {$('img').each(function(){var $img = $(this);var filename = $img.attr('src')$img.attr('title', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));});});
</script>



Sau đó chọn Save Template và bạn đã hoàn thành công việc rồi :D
Thank for sharing!

About The Author


Templateify

Praesent nec tortor quam. Quisque ac malesuada augue. Sed dignissim gravida odio ut bibendum. Cras fermentum euismod turpis. Nunc nec diam ante, et faucibus ipsum. Etiam imperdiet mattis elit et molestie. Nulla feugiat mollis leo vel egestas. Pellentesque convallis

0 nhận xét