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

Dirty fix on header_image_file #21

Closed
wants to merge 1 commit into from
Closed

Dirty fix on header_image_file #21

wants to merge 1 commit into from

Conversation

jonata
Copy link

@jonata jonata commented Mar 21, 2021

This is my fix for the header_image_file issue.

if (isset($page->header()->header_image_file)) {
$tmp_images = array_replace([], $images);
foreach ($tmp_images as $image) {
if (basename($image->url()) != $page->header()->header_image_file) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this loop / implementation ?
And why basename for one and not for header_image_file ?
Can you share the interface of header_image_file please ?

Copy link
Author

@jonata jonata Mar 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you asked to see my "dirty" solution and I am not a PHP developer and I don't know a better approach. Sorry about this.

The loop is to create a list with just the header_image_file as an image object. Basename because, usually, we don't put the full URL when we want to point a header element to an image of the page; we just put the filename on it. I did not find a way to get the filename from the image object, but getting it from the url() works. I think I can't "share the interface" of header_image_file, if you are asking for some specific documentation.

Sorry if I bothered you with this. I just wanted a way to specify (force) the plugin to use a specific image as the og/twitter image and not let it just pick the first one. I think that this would be a good way, to follow what Antimatter defined. Setting a custom header element on plugin settings would be another way to do this, so we could use anything, not just header_image_file. But maybe this would be more complicated.

@jonata jonata closed this Sep 7, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants