Jump to content

mike131

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by mike131

  1. I am currently using both the MarkupSEO module and the AmazonS3Cloudfront module. The MarkupSEO module provides an SEO tab where I can add an image url. I think that figuring out the cloudfront url of the image may be a bit too much work for the authors so I am trying to get the Cloudfront URL from AmazonS3Cloudfront module and pass it directly into the image field in MarkupSEO module. I am unable to get it to work and I am a bit lost as to where to start to try to figure this out. I have tried modifying MarkupSEO to call the function from AmazonS3Cloudfront to get the cloudfront url of the image but it is returning null. Any tips on how to go about this?
  2. Thank you @kogondo. I ended up using basically what you said with @Wanze's modification. $cnt = $pages->count("template=foo, created_users_id=$author"); Thank you!
  3. Hi, I checked the docs and the forum but I was unable to see if there was a way to get the number of posts an author has. Any ideas? Or did I miss something in the docs? Thank you!
  4. I figured out my problem, it was due to the name I was naming folders.
  5. Hi, I have a site that has other ccTLDs, such as .co.za, .co.il, etc., I am trying to make a robots.txt for each of the different domains by following this article. http://webmasters.stackexchange.com/questions/61089/serve-a-different-robots-txt-file-for-every-site-hosted-in-the-same-directory When I test however, I get a message saying 'Unable to complete this request due to an error. Error has been logged. Administrator has been notified.' with a 500 error. I don't really know much about htaccess and I am wondering if I need to put something in the processwire htaccess directives to bypass/allow what I am trying to do. The end result would be. Request is http://example.co.uk/robots.txt is redirected to /co.uk/robots.txt
  6. Thank you so much for this !!
  7. I want to change pages where you would get a simple page that says Unable to complete this request due to an error. Error has been logged. Administrator has been notified. To show a 404 page in the templates folder instead. How do I go about doing this? Thank you! EDIT: I do have a 404 page at example.com/404 So for me, there are a bunch of children items under example.com/about, such as example.com/about/resource example.com/about/team I want example.com/about to go to the 404 page since there is nothing there, only the children.
  8. Hi horst, thank you for your help again. I The function that I am using to hook after executeresize is: /* Resizes image and sends to cloud */ public function sizeBlogCloud($event) { $image = $event->object->getPageImage(); $width = (int) $this->input->get->width;//$event->arguments(0); $height = (int) $this->input->get->height; //$event->arguments(1); $options = is_array($event->arguments(2)) ? $event->arguments(2) : array(); // optional //$resizedImage = $image->size($width, $height, array('suffix' => array('is'))); if ($width < $image->width) { // add a suffix if it is a resized version, don't add a suffix if it is the original unresized image $suffix = isset($options["suffix"]) ? $options["suffix"] : array(); $suffix = is_array($suffix) ? $suffix : array($suffix); $options["suffix"] = array_merge($suffix, array("is")); } $resized = $image->size($width, $height, $options); $filename = $resized->filename; // Add to S3 $s3path = $image->page->id . "/" . $resized->name; $pathToFile = $filename; //var_dump($pathToFile); //return; $s3args = array( 'Bucket' => $this->s3_bucket, 'Key' => $s3path, 'SourceFile' => $pathToFile, 'ACL' => $this->select_acl, 'Metadata' => array( 'original_url' => $resized->url, 'info' => 'Uploaded via the AmazonS3Cloudfront PW Module' ) ); if(is_int($this->cache)) { $s3args['CacheControl'] = 'max-age=' . $this->cache; } try { $result = $this->client->putObject($s3args); } catch(Exception $e) { throw new WireException("Error: File not added to S3: {$e->getMessage()}"); } // Return the resized object return $resized; } One issue I am seeing now is that the file that gets saved to the cloud looks like: cache.example.com/files/1332/screen_shot_2014-11-18_at_12_38_09_pm.825x0-is.png while the file that the blog body looks for is: cache.example.com/files/1332/screen_shot_2014-11-18_at_12_38_09_pm.825x263-is.png From what I can tell. ProcesswireBlog module saves the <img> tags in the blog body to the database, so I am using $blog_body = str_replace('serverPathToFiles', 'cloudPathToFiles', $blog_body); So there is a difference between what is saved and the resized filename. Any ideas on why this could be? Am I calling size when it should really be a width call?
  9. So it almost works. It is uploading the resized image, however the image the blog post is looking for is not the same as what gets saved. The image that gets saved is screen_shot_2014-12-05_at_1_11_11_pm.540x0.png The image that the blog tries to use is screen_shot_2014-12-05_at_1_11_11_pm.540x0-is.png It seems to append -is to the filename. I am not sure where this is coming from and dont want to just append '-is' in the filenames, I would rather try to get this working properly.
  10. Will try it out and report back. Thank you!
  11. I don't think this is it. I think it is ProcessPageEditImageSelect.module. I see the ___executeResize function returning the response that I see from the url. I want to try to hook after this function in order to take that file and upload it to to cloud. $this->addHookAfter('ProcessPageEditImageSelect::executeResize', $this, 'sizeCloud'); When i do this, the resize call's response is now: {"error":true,"message":"Method ProcessPageEditImageSelect::size does not exist or is not callable in this context"} Any ideas on what could be the issue? EDIT: The sizeCloud function (which is located in a third party module): /* Resizes image and sends to cloud */ public function sizeCloud($event) { $image = $event->object; $width = $event->arguments(0); $height = $event->arguments(1); $options = is_array($event->arguments(2)) ? $event->arguments(2) : array(); // optional $resizedImage = $image->size($width, $height, $options); $filename = $resizedImage->filename; // Add to S3 $s3path = $image->page->id . "/" . $resizedImage->name; $pathToFile = $filename; //var_dump($pathToFile); //return; $s3args = array( 'Bucket' => $this->s3_bucket, 'Key' => $s3path, 'SourceFile' => $pathToFile, 'ACL' => $this->select_acl, 'Metadata' => array( 'original_url' => $resizedImage->url, 'info' => 'Uploaded via the AmazonS3Cloudfront PW Module' ) ); if(is_int($this->cache)) { $s3args['CacheControl'] = 'max-age=' . $this->cache; } try { $result = $this->client->putObject($s3args); } catch(Exception $e) { throw new WireException("Error: File not added to S3: {$e->getMessage()}"); } // Return the resized object return $resizedImage; }
  12. Sorry, I thought it would be more appropriate here. Will go back to the first post
  13. Hi all, I have TinyMCE that is being used for blog posts. When inserting images into the editor, it can resize images. I would like to know where that resize call happens. I believe the call to resize is going here /admin/page/image/resize?id=1331&file=1331,screen_shot_2014-12-05_at_1_11_11_pm.png&width=825&height=671 My goal is to try to hook or "hijack" the resize in order to take the resized image and upload it into the cloud. Any ideas or pointers? Thank you!
  14. Hi I am trying to figure out where TinyMCE or Processwire makes the call to resize images in a blog post. The URL i see for the resize call is /admin/page/image/resize?id=1331&file=1331,screen_shot_2014-12-05_at_1_11_11_pm.png&width=825&height=671 I would like to know where I can look to see the actual function that is called from this url. Please let me know if this is unclear. Thanks in advance!
  15. Sorry, I think I misunderstood how to use this. Thank you so much for your help Horst!
  16. I think there may be a slight misunderstanding. In the Admin, there are a few fields setup, such as top_image. (Admin > Setup > Fields). This field shows up as Inputfield type image. I am currently working to expand the AmazonS3Cloudfront module to be able to take the file that is resized and upload it to the cloud. In the template for instance, I have: $page->image->size2cloud(1280, 0); // This works $page->top_image->size2cloud(1280,0) // Does not work. I was wondering if there was a class to add the size2cloud hook to, so that ANYTIME size is called, I can take over with the size2cloud function. I hope this makes sense. If it doesnt please let me know.
  17. Thank you Horst! I just checked and noticed that there are custom fields in the admin, where the addHook do not work. I see that the InputField type is Image. Is there a way to hook the function to any type of resize call? Sorry, for all these questions. https://processwire.com/api/fieldtypes/images/
  18. Ok so i think this will work. Is there a way for me to access which "page" the image belongs too? I know I can just search "file/1231/resizedimage.1280x0.jpg" for the 1231 portion, but I would like to use built in functions if they exist. Thank you!
  19. Hi horst, I think this is exactly what I need! Let me implement and test and I will get back.
  20. Also, just a question of understanding. Does $this->addHook('Pageimage::size', $this, 'resizeTest'); actually override the Pageimage::size function? EDIT: Ideally, i would just want to hookAfter, to receive the file so I can then upload it to s3.
  21. Hi all, I am currently using a module called AmazonS3Cloudfront. An issue that I am having is that the templates use ->width() to dynamically resize images. I see that size method is hookable, so I can change width calls to use size($width, 0) instead. I am a little confused on the $event parameter that is passed into the hook. Currently I am using. $this->addHook('Pageimage::size', $this, 'resizeTest'); and in resizeTest, i get the $event, but not too sure what is actually being passed. My end goal is to either rewrite size() or hookafter size(), so that I can take the file generated from the resize and place it into my s3 bucket. Any pointers on figuring out this $event parameter? Thank you!
  22. Checking the assets folder was my first attempt to resolve. I had the assets folder and its child directories set to 755 I also made sure the apache server user/group owned those directories as well.
  23. Hi, I currently have 2 servers behind a load balancer. Each of these servers are running processwire, but there is an issue with files management (site/assets/files) Each one would have a separate set of files depending on which server you "hit" when you make changes/upload. Does anyone know of a good way to handle this without losing files? Thank you!
  24. @DaveP it looks like that solved it. I changed this setting and it seems to be working so far. I am not 100% sure from the user's standpoint, but since my user's are verified authors. I think it will be okay to leave this off @Ben I will look into this as well if @DaveP's fix doesn't seem to be it.
×
×
  • Create New...