Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
05-16-2024, 01:14 PM
|
#16
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,126
|
Quote:
Originally Posted by Bala451987
"Hey, I gave it a shot and responded, but I encountered a fatal error. I might need your support later on." I am trying to find out. Thanks for your support.
|
No, you didn't...you posted the line of code that originally gave an error, and followed up with:
"I tried but have some fatal error, the code i tried having issue. I am not a tech savvy person. I am just a beginner so i tried with the advices given here."
You get "some fatal error", don't tell or show us what you did/tried, or how...and still expect us to be able to do something.
|
|
|
05-18-2024, 08:20 AM
|
#17
|
Member
Registered: Aug 2023
Location: India
Distribution: Right now with LMDE
Posts: 61
Original Poster
Rep:
|
Bro i responded after i tried with the code provider by Nevemteve. So by using that code i faced this kind of error. Take it easy why did you get tensed to this? When i did not sort out this issue, I came to this support. It is not a big deal. Thanks.
|
|
|
05-19-2024, 11:19 AM
|
#18
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,126
|
Quote:
Originally Posted by Bala451987
Bro i responded after i tried with the code provider by Nevemteve. So by using that code i faced this kind of error. Take it easy why did you get tensed to this? When i did not sort out this issue, I came to this support. It is not a big deal. Thanks.
|
No one is 'tensed' besides you. All you posted after what nevemteve gave you was "encountering fatal error, let me check". Doesn't tell anyone much, does it???
You seem to do this in most of your threads, where you don't follow up, claim to not know things (despite being told), and won't try what you're given. Again; you were given a clear list of things to try, and were told what the error was. Not much else we can do to help you, if you won't do anything on your own.
|
|
|
05-20-2024, 12:22 AM
|
#19
|
Member
Registered: Aug 2023
Location: India
Distribution: Right now with LMDE
Posts: 61
Original Poster
Rep:
|
Quote:
Originally Posted by TB0ne
No one is 'tensed' besides you. All you posted after what nevemteve gave you was "encountering fatal error, let me check". Doesn't tell anyone much, does it???
You seem to do this in most of your threads, where you don't follow up, claim to not know things (despite being told), and won't try what you're given. Again; you were given a clear list of things to try, and were told what the error was. Not much else we can do to help you, if you won't do anything on your own.
|
I wasn't stressed. I attempted to use the provided code, but I encountered a fatal error. Afterward, I removed the code. It's not a big deal; let's just leave it. If I have trouble understanding you, I'll let you know. Thanks.
P.S.: I didn't note the fatal error because I ran into another issue. So, I'm currently working without implementing lazy load. Just for your information, I'm using a plugin with lazy load function, but I'm not satisfied with it, so I reached out to the community to implement it through coding.
|
|
|
05-20-2024, 07:47 AM
|
#20
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,126
|
Quote:
Originally Posted by Bala451987
I wasn't stressed. I attempted to use the provided code, but I encountered a fatal error. Afterward, I removed the code. It's not a big deal; let's just leave it. If I have trouble understanding you, I'll let you know. Thanks.
P.S.: I didn't note the fatal error because I ran into another issue. So, I'm currently working without implementing lazy load. Just for your information, I'm using a plugin with lazy load function, but I'm not satisfied with it, so I reached out to the community to implement it through coding.
|
So again: - You don't post the actual error you get.
- You got at least three different solutions with file names and documentation, but don't say what (if anything) you actually tried or how.
Since it's PHP, it is 'through coding'...which is why you were given the names of functions to try, with documentation/examples. Not much else anyone can help you with, since you don't appear to be doing anything with what you've got.
|
|
|
05-21-2024, 11:17 PM
|
#21
|
Member
Registered: Aug 2023
Location: India
Distribution: Right now with LMDE
Posts: 61
Original Poster
Rep:
|
Quote:
Originally Posted by TB0ne
So again: - You don't post the actual error you get.
- You got at least three different solutions with file names and documentation, but don't say what (if anything) you actually tried or how.
Since it's PHP, it is 'through coding'...which is why you were given the names of functions to try, with documentation/examples. Not much else anyone can help you with, since you don't appear to be doing anything with what you've got.
|
Already answered to your question here in the above answer. Thank you.
|
|
|
06-17-2024, 04:43 AM
|
#22
|
LQ Newbie
Registered: Jun 2024
Posts: 1
Rep:
|
It's definitely okay to ask WordPress questions here. It looks like you're trying to implement a lazy-load function for images but encountering an error. The error message suggests that WordPress can't find your function 'add_lazyload_to_images'.
Ensure that the function is defined before it's called. Also, try adding your function in a different hook like 'init'. Here’s an updated version of your code:
function add_lazyload_to_images($content) {
if (is_admin()) {
return $content;
}
$content = preg_replace('/<img([^>]*)src=["\']([^"\']*)["\']([^>]*)>/i', '<img$1src="$2" loading="lazy"$3>', $content);
return $content;
}
add_action('init', function() {
add_filter('the_content', 'add_lazyload_to_images');
});
This ensures the function is available when needed. Hope this helps!
|
|
|
06-17-2024, 07:35 AM
|
#23
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,126
|
Quote:
Originally Posted by thomasmuller
It's definitely okay to ask WordPress questions here. It looks like you're trying to implement a lazy-load function for images but encountering an error. The error message suggests that WordPress can't find your function 'add_lazyload_to_images'.
|
Right...which is what the OP was told initially, and also given this advice:
Quote:
Ensure that the function is defined before it's called. Also, try adding your function in a different hook like 'init'. Here’s an updated version of your code:
Code:
function add_lazyload_to_images($content) {
if (is_admin()) {
return $content;
}
$content = preg_replace('/<img([^>]*)src=["\']([^"\']*)["\']([^>]*)>/i', '<img$1src="$2" loading="lazy"$3>', $content);
return $content;
}
add_action('init', function() {
add_filter('the_content', 'add_lazyload_to_images');
});
This ensures the function is available when needed. Hope this helps!
|
Anything else from ChatGPT?
|
|
|
06-20-2024, 07:57 AM
|
#24
|
Member
Registered: Aug 2023
Location: India
Distribution: Right now with LMDE
Posts: 61
Original Poster
Rep:
|
Quote:
Originally Posted by TB0ne
Right...which is what the OP was told initially, and also given this advice:
Anything else from ChatGPT?
|
Thanks and i will implement and let you know. Sorry for delayed response.
|
|
|
06-20-2024, 08:05 AM
|
#25
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,126
|
Quote:
Originally Posted by Bala451987
Thanks and i will implement and let you know. Sorry for delayed response.
|
That is the same advice you've been given since the first reply. Same things you've been pointed to for documentation, along with other suggestions as to where to put this function. Seem to ignore it all.
|
|
|
All times are GMT -5. The time now is 03:19 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|