Concrete5: An image could not be created from the given input - php

Using Concrete5 8.1, I am getting the error An image could not be created from the given input on every page.
I created a custom theme, custom Thumbnail sizes, and custom Page Types, most of the site content has been entered and everything was working well. In reviewing the site before it goes live, I noticed most of the images had been uploaded as fairly large images (2000-4000 pixels wide, nothing insanely huge, but large enough that I wanted to do something about it).
Based on the Concrete5 documentation, I added the following code:
public function getThemeResponsiveImageMap() {
return array(
'timeline_gallery' => '0'
);
}
The timeline_gallery thumbnail has existed since the start of this project, so all images should have already had this thumbnail. But when I refreshed the page, I see the error: An image could not be created from the given input.
Google finds many entries for this error: potentially related to GD not being able to process SVG, PNG, or very large images, and the solution is to address the problem images within the File Manager. However, I cannot get to the File Manager - I cannot get to any page on the site, including any of the dashboard pages (all display the same error).
I then remove the 5 lines of code from above (the only code changes that have taken place over the past 24 hours) and save the page_theme.php, but I still see the same error on every page.
It would be great to be able to fix the image sizes, but at this point, I'd just like to clear the error and make the site work again. I have looked at the Apache log for any specifics on the error (no help, since the error doesn't show up), I have restarted Apache, and then rebooted the machine (all to no avail). With the code being the same as when the site was working earlier today (and all content editors have left, so no content changes have taken place), I'm guessing there might be a queue, either in the file system or database, of images to be resized and one of them is causing an issue... but it's just a guess.

You can clear the error by modifying the FileImageThumbnailPaths table.
Find the table entry where isBuilt is 0.
SELECT * FROM FileImageThumbnailPaths WHERE isBuilt = 0;
In the results, change the entry isBuilt column to 1.
If you have multiple entries to change, you can change them all at once.
UPDATE FileImageThumbnailPaths SET isBuilt = 1 WHERE isBuilt = 0;
Using phpMyAdmin:
select your concrete5 database
click the SQL tab in the top menu bar in the right pane
in the textarea, you can enter the SQL query
Before making any changes to the database, please make a full backup of your database and site files.

Related

Some phpThumb images come up broken

I have a page in my site that uses a MySQL database and a PHP script (phpThumb) to create small (150px-wide) images from larger images. When I ask it to display this page:
https://newtonartassociation.com/membership/admin/mb_test.php
some of the images come up as broken.
If I reload the page, some of the broken images get filled in but others usually break. For some reason it is worse in Firefox than Chrome. Note that (1) there are more broken images at the far end of the page than at the beginning; and (2) if I invert the list order, I still get more broken images at the far end, so it doesn't seem to be the individual images that are causing this.
The only change since the last time I ran this code is that I'm now running PHP 7.0 instead of 5.6.
I got the latest version of phpThumb and I also tried reverting to PHP 5.6 but got the same result.
<?php
$result_art = $mysqli->query("SELECT * FROM eventart WHERE (event = 'motherbrook') ORDER BY artist ASC");
$row_result_art = mysqli_fetch_assoc($result_art);
require_once('../resize/phpThumb.config.php');
do {
$image = $row_result_art['artworkid'];
echo '<img src="'.htmlspecialchars(phpThumbURL('src=show_images/'.$image.'&w=150', '../resize/phpThumb.php')).'"><p>';
} while ($row_result_art = mysqli_fetch_assoc($result_art));
?>
If I right-click on a broken image and select reload image (Firefox) or open in a new tab (Chrome), I see the image and it then appears in the full list, but I can't instruct my client to do this for every broken image.
You are uploading too many images at the same time. Browsers save data.
Cut the pictures into pieces and show them if the user wants to see them.

Found some 404s for image files in statistis

I am running a website in which I generate dynamic images for users. Initially, I was saving all the images generated forever so that I can use those images when required to be shown again but since recently I started getting some decent traffic, so I thought instead of saving and reusing the images I should generate them again when they need to be shown again.
Now what I am doing is: I have created a temp folder and I save every image in that temp folder and show it to user. And when this image is required to be shown again, I just re-create that image instead of using this temp image. And temp folder is now emptied at sometime daily.
But now I have started getting 404s in my error logs for the images. I am not getting that from where I am getting those 404s since I myself tried deleting image from tmp and then revisited that page. The image was re-created and was shown properly. I am badly stuck at this. One thing I would like you to tell is that I am allowing user to share those result-pages(with images) on social networks.
So it is like:
I create one image in tmp and show it on some result.php page. I
also put the image's link in og meta tag so that it can be properly
identified by social networks while sharing.
If somebody visits result.php page again, then it shows image again. However, if image is not available(i.e. deleted as daily
job), then it recreates it first, saves at that location and then
shows the page.
I am getting 404s for .jpg image files in error log.
On debugging it more, I found that these 404s are there because of access to images from Facebook IPs. The IPs from which 404s are detected are like: 66.220.158.119, 173.252.101.116, etc. On some googling, I founf that these IPs are allocated to Facebook.
So it means: facebook bot is accessing the images because these links were earlier shared on facebook via facebook share. Can someone please tell me is there any harm if later(say after 1 day of sharing), if facebook does not find the image anymore on my server? Will it not show anymore on shared link on facebook also?

Image isn't refreshed on application

I'm working on a PHP application to store some personal information (including photo). I'm storing the image on a specific folder (let's say myapp/images/people/).
After saving a photo my app is redirected to a page showing the information of the specific person (kind of a profile).
If the photo is saved for the first time (no other photo was previously saved for that person) then the photo is shown in the profile. Everything seems to work at this point.
The problem is when I want to change the photo. When I replace a photo my applications keeps showing the old one. I've checked the server and the old photo is gone, there's only the new one (as I need) but the application doesn't show it.
I guess it's something to do with cache.
I've tried by adding the html tag with no cache values, I've tried by adding the same values by using the header() PHP function but nothing.
I also tried by using:
if(file_exists($imagepath))
{
unlink($imagepath);
}
and similar I've used
if(file_exists($imagepath))
{
unlink($imagepath);
clearstatcache();
}
but also nothing.
Can someone help me with this? Any idea about what's going on? The new photo is in the server, the old one is not but the app keeps showing the previous file.
The image is cached in the browser. The best way is to generate a new image name on the server and return the new image in the HTML. Since it is a new image for the browser, it won't get it from the cache and you will see the new image in the application.

Any way to make image (gd lib) show only on specific page only?

I'm trying to figure out the logistics for a new site that I'm creating, and one of the main issues is to get verification working correctly. One of the verification methods i'd like to incorporate is for a specific image (created via gdlib on the fly) to only work on a web page that is specified in a database field. If the image is shown on the EXACT page that is specified, then it shows the correct image, and if the link is incorrect, then it shows a different image (set by admin). The fields will be created on the admin side, and I'm trying to figure out how to get multiple instances of this working correctly. I'm using PHP and using a tag like [img src="something_here.php"] to show my images. Any suggestions on how to set the coding to verify the site that the image is embedded into?
Update So I got it working, but the request_URI command only works for the extension "ex. login.php", as opposed to adding in the absolute domain also. Any suggestions on how to make it factor in the whole domain address?
If you create an image with gd, you can put any PHP code on the page. for example: if ($_SERVER['REQUEST_URI'] == '/specialWebPage.php') { ... }.

A good solution for displaying galleries with lytebox and php

I have thought for a while over an issue with the loading of images on a website-solution that I have programmed (For fun and the experience)
The programming language used is PHP with MYSQL as the database language
It also uses javascript, but not extensively
I have recently realized that the engine I programmed, while it has it's smart solutions also carry a lot of flaws and redundant code. I have therefore decided to make a new one, now incorporating what I know, but didn't when I started the previous project.
For the new system, there will be an option to add galleries to a site, and upload images to it. I have used the javascript image viewer Lytebox before. The screen goes dark and an image appears with a "Previous" and "next" button to view the other images.
The problem is that I used groups with lytebox and the images themselves, resized as thumbs. This causes lytebox to work only when all the images have loaded. If you click a link before that, the image is shown as if you right click and choose "Show image"
Information about these images is parsed from a database using a while statement with a counter that goes from 0 to sizeof()
I'm thinking it probably isn't a good idea to have the images as the thumbs, even if you restrict the upload size. Likewise, adding thumbs at upload also seems like a hassle. It would be practical if the thumbs didn't show up before they were fully loaded.
Has anyone got any good tips. Any help would be appreciated.
Johann
Not really. What I would like to know is what route to go when creating a page that lets you upload images. Does other systems usually create thumbs-files when a user uploads a file? Is there a way to display images on the server as thumbs that doesn't require you to load the entire image?
What would also work would be to get lytebox to pop up, with a white frame and "wait" for the image. Basically everything else than opening the image as a regular link.
I had an account here before, seems like it has been reset or something. Tried logging on with both google open-ids. Wouldn't let me comment your comment so I had to do it the hard way and answer my own post :|

Categories