-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[4.1] Images in the Smart Search results #32450
Changes from 34 commits
c45283a
28349ba
7bb1cde
3a31d12
e998b40
61a416e
9220a51
9160bc8
c5a569f
caffe18
bd0bb74
005683f
46527b0
de578a4
17e7970
60df430
ade0566
a499732
f50a8a8
4faff60
f3f8b70
f5cf2a9
1fa0e3d
e6d833e
fcb3817
567096d
17042f6
1949eaa
20dc24e
f0a72de
896e612
115b924
66be9c1
78f8a69
c2e4b7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,6 +295,15 @@ protected function index(Result $item) | |
$item->title = $title; | ||
} | ||
|
||
$images = json_decode($item->images); | ||
|
||
// Add the image. | ||
if (!empty($images) && $images->image_intro) | ||
{ | ||
$item->setElement('imageUrl', $images->image_intro); | ||
$item->setElement('imageAlt', $images->image_intro_alt ?? ''); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. look how $item->imageUrl = $images->image_intro;
$item->imageAlt = $images->image_intro_alt ?? ''; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is exactly how it was before pointing me out to use the getters/setters. Probably you are commenting without checking my commits. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, here it was correct before,
It was about Result class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry i cannot go back and forth. I am closing that as resolved since it works and it's indeed much better than setting public properties. For any further change please commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, title was a bad example sorry, however please do: $item->imageUrl = $images->image_intro;
$item->imageAlt = $images->image_intro_alt ?? ''; No need to create any properties, just do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Obviously you did not bother to examine the finder's code, neither to test what you are writing. |
||
} | ||
|
||
// Add the meta author. | ||
$item->metaauthor = $item->metadata->get('author'); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do not need use
empty
check, just do:Remember we have a __get
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->result->imageUrl
and$this->result->imageAlt
no longer exist, based on the last commit.The imageUrl and imageAlt are now part of the Joomla\Component\Finder\Administrator\Indexer\Result::$elements
which can only be accessed through the
__get()
or thegetElement()
functions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, do you know what
__get()
/__set()
doing? :)Please check how the code access to $item->title and other values.
Correct, they not need to exist. That is magic of magic methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test your suggestions before writing them down.
$this->result->imageUrl
and$this->result->imageAlt
are null since they do not exist.If you want to provide a working example based on that suggestion, please commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is null only when it empty,
if you set a value while indexing then it will be not null here