WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
[resolved] Attachment links' query strings interfering with jQuery detection (10 posts)

  1. leggo-my-eggo
    Member
    Posted 2 years ago #

    The W3 Total Cache plugin is really amazing.

    I've got a CDN working with CloudFront and Amazon S3. Super easy to set up.

    But now if I insert an image into a post, linked to the large version of itself, the link has an appended query string, like this:

    http://mysite.s3.amazonaws.com/wp-content/uploads/2012/02/image.jpg?d4ad4

    My problem is that the query string seems to be confusing my jQuery popup plugin's ability to realize that this image is a jpg.

    Anyone know a way around this? The jQuery in question (in the Easy Fancybox plugin) uses the "Attribute Ends with" Selector in jQuery (http://api.jquery.com/attribute-ends-with-selector/) like this:

    $('a[href$=".jpg"]')

    So, I suppose the query string just makes it so that that condition is no longer met.

    http://wordpress.org/extend/plugins/w3-total-cache/

  2. Frederick Townes
    Member
    Plugin Author

    Posted 2 years ago #

    You can disable the option on the browser cache settings tab, but it would be best for that plugin to be updated to understand query strings. The query string allows you to change your browser cache settings or the the contents of the jpg and have your users be able to download the updated version without flushing their caches (which they wouldn't know to do).

  3. leggo-my-eggo
    Member
    Posted 2 years ago #

    Makes sense. Do you (or anyone) know the appropriate jQuery selector(s) for identifying links to images which won't get confused by query strings?

  4. blank81
    Member
    Posted 2 years ago #

    hi Frederick,
    am trying to active the themes but i got this error " Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 30720 bytes) in /home/mdvcommy/public_html/en/wp-content/plugins/w3-total-cache/lib/W3/Plugin/TotalCacheAdmin.php on line 2909" please advice how to fix it? i already changed the permission to 777 for both dir that you said in your installation page.
    -Nizam

  5. MathiasBauer
    Member
    Posted 2 years ago #

    PHP has a memory problem. Raise your memory size in the file php.ini

    -Mathias

  6. leggo-my-eggo
    Member
    Posted 2 years ago #

    @blank81, why hijack this thread about a completely different topic?

    This question is about jQuery selectors breaking due to query strings added by W3 Total Cache to prevent browser caching when settings have changed.

    Please start a new thread to ask a new question.

  7. leggo-my-eggo
    Member
    Posted 2 years ago #

    OK, through a conversation over at http://stackoverflow.com/questions/9501929/jquery-selector-for-links-to-images-which-tolerates-query-strings I've come to the conclusion that the selectors should probably just be $(a[href*=".jpg']), which has the liability of being fooled by URLs like http://example.com/img.jpg.aspx, but I think in my case is better than not having the query string.

    I've found a way to modify the Easy Fancybox plugin, which you can see the progress of in this thread:

    http://wordpress.org/support/topic/plugin-easy-fancybox-modify-img-selectors

  8. leggo-my-eggo
    Member
    Posted 2 years ago #

    The developer of the Easy Fancybox plugin, @RavanH, has been very responsive and is testing changing the jQuery selector for image links to href*= to accommodate the possibility of a query string. Wonderful!

  9. Frederick Townes
    Member
    Plugin Author

    Posted 2 years ago #

    So you're all set and your memory issue is also resolved?

  10. leggo-my-eggo
    Member
    Posted 2 years ago #

    Yes, thank you! I think this is now resolved.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic