OpenGraph icon indicating copy to clipboard operation
OpenGraph copied to clipboard

include Title tag too?

Open jayenne opened this issue 4 years ago • 3 comments

Although not technically a meta tag, the title tag would be a handy addition as it is an arbitraty informative label too.

With a tiny addition between the $metadata decleration the $tags as $tag loop to create a$metadata['title'] key val pair, one could add the given title too.

        if($allMeta){
            $title = $doc->getElementsByTagName('title');
            $metadata['title'] = $title->length > 0 ? $title->item(0)->textContent : null ;
        }

By putting it here, should there be a metata tag called title too, it would override this value for the preffered one.

jayenne avatar Oct 14 '21 09:10 jayenne

@jayenne so, if metatag title is present it should return the metatag title else it should check for the title tag and return?

shweshi avatar Oct 14 '21 09:10 shweshi

Yes, (IMHO*), I've submitted a PR for this too.

*I think if a site goes to the trouble of including an meta title in addition to the title tag then I think it would be the meta title they'd rather be used. agree?

jayenne avatar Oct 16 '21 10:10 jayenne

@jayenne feature wise I agree this would be a valuable addition. Although since this package is specific to fetch meta tags. And ideally if the title tag is not present it shouldn't return. People might be using this if tests cases too.. to check if title is present, title is not present.

I looked into the PR I would suggest it would be better if we let the consumer know what is happening under the hood, that title is taken if meta title is not there. Also I would suggest if we let consumer decide whether they want title tag or not if meta title is not present.

Let me know your opinion.

shweshi avatar Oct 16 '21 17:10 shweshi