A
A
alex steel2017-02-12 09:47:57
Search Engine Optimization
alex steel, 2017-02-12 09:47:57

How to generate alt and title for an image?

On each page of the site (online store) there is a product name in H1
How to generate alt and title for short images will be like H1 on the page?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Otrivin, 2017-02-12
@Otrivin

It all depends on the CMS. What is used?
Basic knowledge of php is required.

A
Ankhena, 2017-02-12
@Ankhena

Something like that:

var alt = $("h1").text();
    		$.each($('img'), function(){
    			if ($(this).attr("alt").length == 0) {
    		   		$(this).attr("alt",alt);
    		   	}
    		   	if ($(this).attr("title").length == 0) {
    		   		$(this).attr("title",alt);
    		   	}
    		});

D
Denis Yanchevsky, 2017-02-12
@deniscopro

Maybe the SEO Friendly Images plugin will do . According to the description, it does what it's supposed to do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question