(Translated by https://www.hiragana.jp/)
include Title tag too? · Issue #78 · shweshi/OpenGraph · GitHub
Skip to content
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

include Title tag too? #78

Open
jayenne opened this issue Oct 14, 2021 · 3 comments
Open

include Title tag too? #78

jayenne opened this issue Oct 14, 2021 · 3 comments

Comments

@jayenne
Copy link

jayenne commented Oct 14, 2021

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.

@shweshi
Copy link
Owner

shweshi commented Oct 14, 2021

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

@jayenne
Copy link
Author

jayenne commented Oct 16, 2021

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?

@shweshi
Copy link
Owner

shweshi commented Oct 16, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants