• After installing the Amazon Cloudfront and S3 plugin, we tried to add the images back to a slider, so that they were loaded from CloudFront instead of the local drive. The images show up as blank. Note that we are using Elastic Beanstalk and load balancing, so newly launched servers only have access to images through the Amazon cloud.

    Also note that I have this box checked in CloudFront and S3 plugin

    “Remove uploaded file from local filesystem once it has been copied to S3”

    So I think that the Meta Slider is looking for files on the local file system and not in Amazon CloudFront

    https://wordpress.org/plugins/ml-slider/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Did you find a solution to this problem?
    We are have the same issue. May be there is a different slider we can use.

    I found that if you change line 28 of inc/metaslider.imagehelper.class.php the image will show up. You still get the error message on the admin page.

    From: $this->url = $upload_dir[‘baseurl’] . “/” . get_post_meta( $slide_id, ‘_wp_attached_file’, true );

    To: $this->url = wp_get_attachment_url($slide_id);

    This pulls the correct URL for the attachment

    I have updated my hack. Make the following changes to ml_slider/inc/metaslider.imagehelper.class to have ml_slider work with S3 and CloudFront plugin.

    From:

    $this->id = $slide_id;
    $this->url = $upload_dir['baseurl'] . "/" . get_post_meta( $slide_id, '_wp_attached_file', true );
    $this->path = get_attached_file( $slide_id );

    To:

    $this->id = $slide_id;
    $this->url = wp_get_attachment_url($slide_id);
    $this->path = get_attached_file( $slide_id );
    apply_filters('get_attached_file', $this->path, $slide_id);

    hack is a bad decision, why not a developer fixes the problem ????

    True, I posted here hoping that it would make it into a future release.

    Autor plugin suggested that it is possible to use the filter in, look here https://wordpress.org/support/topic/metaslider-with-s3-cloudfront-plugin?replies=3

    I just looked at that filter and the problem with using it is that you have the build the S3/CloudFront URL your self. That filter does not get the post ID.
    The Amazon S3 and CloudFront plugin by Brad Touesnard has the proper filters registered to return the correct URL and file path if you use the WP functions. This is what my hack does. I just wish that it was not needed, or at the very least the developer fixes it.

    Eclyps19

    (@eclyps19)

    I agree with kyllagdrgn – this plugin shouldn’t be manually concatenating the pieces of the URL when there’s a proper hook to fetch it.

    Hi all,

    I’ve added a filter in the latest version (3.3.3) which will let you fix this.

    This code should go into your themes functions.php file (make sure you read the phpdoc):

    https://gist.github.com/tomhemsley/c05c662af05c5015ce12

    To be perfectly honest, I cannot remember why the URL is being built manually. It seems like a bad idea to me too.

    The problem I have now is, if I just changed it to use wp_get_attachment_url I would break the slideshows for anyone who is using the Amazon S3 cloudfront (users who either they realise their images are being served from their own server, or they don’t mind). This is because Meta Slider creates it’s own image sizes which won’t be synced to S3. If Meta Slider suddenly switches to looking for those images on S3, it won’t find them.

    Using a filter means you can get compatibility with S3, and I don’t break anyones stuff. Hopefully this is a good enough compromise 🙂

    Regards,
    Tom

    This sounds good to me. I most certainly do not want to have any thing break for anyone either. I now need to go adjust my customizations. Thank you.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Images do not show up in Meta Slider when I use Cloudfront and S3 plugin’ is closed to new replies.