mcloone
Forum Replies Created
-
Forum: Plugins
In reply to: [Airpress] Project dead?Phew! that’s great to hear. Looking forward to seeing the demo website ??
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueSo I started to get a similar execution error using my script on the pages with tons of images. I fixed it by changing max_execution_time to 180. I tried cacheimagefields after doing this but it still timed out. I’m still getting doubling up of images but haven’t spent time looking at that yet.
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueweird, I did add it just now but think I accidentally deleted it when editing. I just noticed that for some reason it’s doubling up the images so I need to fix that. I initially did this when I only needed to load in one image per page so it’s probably tripping over itself. But basically it goes through each image at a time, looks if it’s in wordpress, if not then uploads, refreshes and (hopefully) moves on to the next.
This is my upload function:
function uploadRemoteImage($image, $name, $id = null){ $get = wp_remote_get( $image ); $type = wp_remote_retrieve_header( $get, 'content-type' ); error_log($image. ' ' . $name); if (!$type){ return false; } $mirror = wp_upload_bits( basename( $image ), '', wp_remote_retrieve_body( $get ) ); if ($id){ $attachment = array( 'post_title'=> $name, 'post_mime_type' => $type, 'ID' => $id, ); } else { $attachment = array( 'post_title'=> $name, 'post_mime_type' => $type, ); } $attach_id = wp_insert_attachment( $attachment, $mirror['file'] ); require_once(ABSPATH . 'wp-admin/includes/image.php'); $attach_data = wp_generate_attachment_metadata( $attach_id, $mirror['file'] ); wp_update_attachment_metadata( $attach_id, $attach_data ); $url= strtok($_SERVER["REQUEST_URI"],'?'); redirect($url); }
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueThe pre-caching sounds awesome. I think for now I’ll go back to what I did before and use wordpress’s wp_insert_attachment to put the images directly into wordpress. Doing it this way is useful for us as sometimes we want to change the crop of an image without changing the photo that’s on airtable.
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueOK, I updated, removed everything from the cache and started again, same error. I did find a corrupt image in the cache after. This is the error from the logs, the image in log here is the corrupted one.
I loaded everything without the image caching and all images loaded fine so I don’t think it’s a problem with the image. Also, I just check on a different project page with a lot of images and ran into the same error ??AIRPRESS LOADED Projects VirtualPost ^project/(.*)/? 200 1 0.35 Projects?filterByFormula={Slug} = '22-jump-street' 200 132 1.4 Portfolio?filterByFormula=OR(...one of 132 ids...) wp_get_image_editor error: file exists /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/Portfolio/att8D57459VdxCJYz-full-image.jpg ######################################### WP_Error Object ( [errors] => Array ( [invalid_image] => Array ( [0] => Premature end of JPEG file
/Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/Portfolio/att8D57459VdxCJYz-full-image.jpg’ @ error/jpeg.c/JPEGErrorHandler/322
))
[error_data] => Array
(
[invalid_image] => /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/Portfolio/att8D57459VdxCJYz-full-image.jpg
))
#########################################
Cached remote image in 0.0147 seconds to /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/Portfolio/attpsuyMZCsbYcUsw.jpg
Cached remote image in 0.0107 seconds to /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/Portfolio/attrpnqNKT91D8AyX.jpg
Cached remote image in 0.0131 seconds to /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/Portfolio/attyTJ1JDJAoRSFim.jpg
Cached remote image in 0.0121 seconds to /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/Portfolio/attbID83pGlpTHz9k.jpg
Cached remote image in 0.0319 seconds to /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/Portfolio/attWDjrtPv2H8inSi.jpg
Cached remote image in 0.0162 seconds to /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/Portfolio/attn84URRgAM8x4di.jpg`Forum: Plugins
In reply to: [Airpress] cacheImageFields issueOk here’s the output:
AIRPRESS LOADED Projects VirtualPost ^project/(.*)/? 200 1 0.4 Projects?filterByFormula={Slug} = '22-jump-street' 200 133 1.92 Portfolio?filterByFormula=OR(...one of 133 ids...) wp_get_image_editor error: /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/attcuZdmCtCfdE31F-full-image.jpg ######################################### WP_Error Object ( [errors] => Array ( [invalid_image] => Array ( [0] => JPEG datastream contains no image
/Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/attcuZdmCtCfdE31F-full-image.jpg’ @ error/jpeg.c/JPEGErrorHandler/322
))
[error_data] => Array
(
[invalid_image] => /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/attcuZdmCtCfdE31F-full-image.jpg
))
#########################################
wp_get_image_editor error: /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/att19145ONOr6ZnGo-large.png
#########################################
WP_Error Object
(
[errors] => Array
(
[invalid_image] => Array
(
[0] => Read Exception `/Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/att19145ONOr6ZnGo-large.png’ @ error/png.c/MagickPNGErrorHandler/1630
))
[error_data] => Array
(
[invalid_image] => /Users/TinymillTim/dev/wordpress/wp-content/airpress-image-cache/att19145ONOr6ZnGo-large.png
))
#########################################
`
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueHitting this error on that one page with a lot of images:
( ! ) Fatal error: Call to undefined method WP_Error::get_size() in /Users/TinymillTim/dev/wordpress/wp-content/plugins/airpress/lib/chetmac/AirpressQuery.php on line 625There’s a total of 133 images trying to be loaded.
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueThanks ??
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueThanks for going through this, although it seems like now there is no file extention at all ??
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueI just went to the Virtual Posts admin and noticed this issue:
Notice: Undefined index: Orientation in /Users/TinymillTim/dev/wordpress/wp-content/plugins/airpress/lib/chetmac/AirpressQuery.php on line 672
I’m also seeing that on the virtual posts, it usually goes away if I do ?fresh=true but weird it’s doing it on the admin page
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueYep I’m on there are Tim_McLoone
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueHey Chester, thanks for this although I’m having trouble with it. It doesn’t seem to be caching the images, but it is adding the related query. If I print out the image array it has the standard airtable stuff. When I look at the logs I see this:
Projects VirtualPost ^project/(.*)/?
200 1 2.51 Projects?filterByFormula={Slug} = ‘project name’
200 21 0.47 Portfolio?filterByFormula=OR(…one of 21 ids…)
Name exists so post_name is Project Name.
Name exists so post_title is Project Name.I wonder if the filter by formula is wrong?
This is the code I’m using (the field in Projects is called Portfolio, as is the table name)
function my_airpress_virtualpost_query($query,$request,$virtual_post_config){ // Ensure we're "targeting" the right VirtualPost configuration if ($virtual_post_config["name"] == "Projects"){ // Create a new Query that will be the related query $portfolio_query = new AirpressQuery("Portfolio"); $portfolio_query->cacheImageFields("Featured Image", array("large","full")); // Add the above query to the Virtual Post query $query->addRelatedQuery("Portfolio",$portfolio_query); $query->cacheImageFields("Featured Image", array("large","full")); } return $query; } add_filter("airpress_virtualpost_query", "my_airpress_virtualpost_query",10,3);
- This reply was modified 7 years, 11 months ago by mcloone.
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueCool thanks for fixing that issue! I had a similar problem with image rotation and ended up using an ios image fix plugin for images I had imported (not using cacheImageFields). I had meant to take a look at the plugin to see how they were doing it, so it is possible.
So the next thing I’m trying to do with cacheImageFields is the following:
a) I’m trying to get an image on an individual virtual post.
b) In that virtual post I’m populating a related field and need to cache image fields for that post.Is this possible?
Forum: Plugins
In reply to: [Airpress] cacheImageFields issueAh I needed to actually create the airpress-image-cache folder for it to work. Next thing – it doesn’t seem to recognise my custom image sizes that have been added in my functions.php. Do I need to add them manually?
This is the error I’m getting:
The provided size of ‘homepage-thumb’ has no width or height params. Skipping.Forum: Plugins
In reply to: [Airpress] addFilter field is not emptyManaged it with
$query->filterByFormula(“{FIELD} != ””)