Post by Joe1234 » Mon Oct 30, 2023 5:15 am

I have a popup function going that isn't really working properly. I have to put a print_r("whatever"); before or after the function for the image to resize

ex: this wont work by itself. It just shows the image at the default set size.

Code: Select all

$data['main']['popup'] = $this->model_tool_image->resize($data['main']['image'], $this->PBLibrary->getImageParam('width', 'popup'), $this->PBLibrary->getImageParam('height', 'popup'));
so to see what was going on I put a print_r() to see the size info that was being passed(which was being passed), then all of a sudden it started working. It works with the print_r before or after the line. I thought maybe it was a time execution or something so I replaced the print_r with sleep of 5 seconds and that didn't work. I put an empty print_r and that didn't work either. Any thoughts?

NOTE: I tried echo and it had the same result as the print_r, and I tried an empty loop of 10000000 and it also had no affect like sleep().

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by softmonke » Mon Oct 30, 2023 4:21 pm

Perhaps you can provide the code to your

Code: Select all

$this->PBLibrary->getImageParam()
function?
Also, could you try logging the what your function is returning using the

Code: Select all

$this->log->write()
function and checking your error logs for the results?

Reach out to us at hello@softmonke.com for your OpenCart web development needs.


User avatar
Active Member

Posts

Joined
Tue May 23, 2023 4:42 am


Post by Joe1234 » Mon Oct 30, 2023 11:01 pm

thanks, logging shows the size value. But that function doesn't even matter, because even when I put the size value directly in:

Code: Select all

$data['bundle']['popup'] = $this->model_tool_image->resize($data['main']['image'], 2000, 2000);
it still wont work without the print_r or echo being placed before or after the line.

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by ADD Creative » Mon Oct 30, 2023 11:41 pm

When you don't have the print_r/echo and it's not working. What are $data['main']['image'] and $data['bundle']['popup'] set to if you log those values to the log?

That might tell you is the issue is with the initial data or the image resizing.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Joe1234 » Tue Oct 31, 2023 1:03 am

That "bundle" was a typo.

It is the same content with or without print/echo. The image name with the size attached to it.

Code: Select all

https://website.com/image/cache/catalog/product/imagename-1500x1500.jpg
Which is the new size it should be but not resizing to unless the print/echo is there.

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by ADD Creative » Tue Oct 31, 2023 3:29 am

When it fails to resize do you see the new resized image file looking in the image cache folder with FTP? What do you get if you put the new resized image URL directly in a web browser? If you view the page source in the web browser is the URL correct? Have you check the PHP and server error logs as well as the OpenCart one?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Joe1234 » Wed Nov 01, 2023 1:34 am

The cache file is created when the print/echo is not put in even though it is not being displayed.
The url of the image is the one that should be showing but isn't.
No errors in the php server log.

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by softmonke » Wed Nov 01, 2023 6:01 am

This is peculiar. Are there any caching that might be causing this problem? Could there be some code down the line that might be modifying the same variable again? Just throwing out random suggestions that I can think of off the top of my head.

What if you simply assign it to a unique variable, like:

Code: Select all

$data['my_variable'] = $this->model_tool_image->resize($data['main']['image'], $this->PBLibrary->getImageParam('width', 'popup'), $this->PBLibrary->getImageParam('height', 'popup'));
And then in your template twig file, you echo it out with:

Code: Select all

{{ my_variable }}
Does that show the correct image or no?

Reach out to us at hello@softmonke.com for your OpenCart web development needs.


User avatar
Active Member

Posts

Joined
Tue May 23, 2023 4:42 am


Post by ADD Creative » Wed Nov 01, 2023 6:47 am

Have you checked the web browser's developer console for errors and inspected where the URL should be?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Joe1234 » Wed Nov 01, 2023 11:51 pm

Here's what I found and I'm stuck as to how to fix it.

First off:
Same issue happens when I put a unique variable.
No errors in the developer console. I don't know what you mean by "inspected where the URL should be".

What I found:
The problem seems to be this javascript that's handling the pop up...or involve the javascript.
1/ When I remove the javascript code the image pops up the full size as it should, but is displayed as a whole new page with a black background instead of in a pop up.
2/ When the javascript code stays I have to put the print/echo for the image to popup and display the proper size within a pop up window.
3/ When I leave the javascript and don't use the print/echo the popup happens in a popup window (which it should) but when I hover over the image, instead of seeing a magnify glass to zoom and make the image larger (to the proper size as I believe is how this should work), it's a pointer and clicking doesn't do anything.

This is the javascript code to activate everything in the twig

Code: Select all

$(document).ready(function() {
	$('.thumbnails').magnificPopup({
		type:'image',
		delegate: 'a',
		gallery: {
			enabled: true
		}
	});
});
This attached zip is the included script that goes in the controller which I can't make heads or tails of to fix this issue. It looks like I'm going to have to fiddle with this for a while to figure out how to make it work together properly (it is condensed, to look at it needs a "beautify" program to make it readable https://beautifier.io/).

All though, with all that, I still don't understand what the print/echo have to do with anything.

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by Joe1234 » Thu Nov 02, 2023 12:19 am

Just figured out how to get what I need. Changed the javascript function to:

Code: Select all

$(document).ready(function() {
	$('.thumbnails').magnificPopup({
		type:'image',
		delegate: 'a',
		gallery: {
			enabled: true
		},
		image: {
			verticalFit: false
		}
	});
});
but my mind is still stuck on the echo/print issue lol. ???

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by ADD Creative » Thu Nov 02, 2023 5:34 pm

By "inspected where the URL should be", I mean to look at the generated page source or use the developer tool to inspect the page source.
https://developer.chrome.com/docs/devtools/dom/#inspect

Although it sounds like the the URL is correct and the problem is with the HTML markup or JavaScript. Echoing a value to the page is changing the HTML markup or JavaScript in someway.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom
Who is online

Users browsing this forum: JNeuhoff and 31 guests