d> 746
+c-37.7998 -37.8008 -58.5996 -88 -58.5996 -141.4s20.7998 -103.6 58.5996 -141.4c37.8008 -37.7998 88 -58.5996 141.4 -58.5996s103.6 20.7998 141.4 58.5996zM328 224c-17.7002 0 -32 14.2998 -32 32s14.2998 32 32 32s32 -14.2998 32 -32s-14.2998 -32 -32 -32zM168 224
747
+c-17.7002 0 -32 14.2998 -32 32s14.2998 32 32 32s32 -14.2998 32 -32s-14.2998 -32 -32 -32zM362.4 160c8.19922 0 14.5 -7 13.5 -15c-7.5 -59.2002 -58.9004 -105 -121.101 -105h-13.5996c-62.2002 0 -113.601 45.7998 -121.101 105c-1 8 5.30078 15 13.5 15h228.801z" />
748
+    <glyph glyph-name="laugh-beam" unicode="&#xf59a;" horiz-adv-x="496" 
749
+d="M248 440c137 0 248 -111 248 -248s-111 -248 -248 -248s-248 111 -248 248s111 248 248 248zM389.4 50.5996c37.7998 37.8008 58.5996 88 58.5996 141.4s-20.7998 103.6 -58.5996 141.4c-37.8008 37.7998 -88 58.5996 -141.4 58.5996s-103.6 -20.7998 -141.4 -58.5996
750
+c-37.7998 -37.8008 -58.5996 -88 -58.5996 -141.4s20.7998 -103.6 58.5996 -141.4c37.8008 -37.7998 88 -58.5996 141.4 -58.5996s103.6 20.7998 141.4 58.5996zM328 296c23.7998 0 52.7002 -29.2998 55.7998 -71.4004c0.700195 -8.5 -10.7998 -11.8994 -14.8994 -4.5
751
+l-9.5 17c-7.7002 13.7002 -19.2002 21.6006 -31.5 21.6006c-12.3008 0 -23.8008 -7.90039 -31.5 -21.6006l-9.5 -17c-4.10059 -7.39941 -15.6006 -4.09961 -14.9004 4.5c3.2998 42.1006 32.2002 71.4004 56 71.4004zM127 220.1c-4.2002 -7.39941 -15.7002 -4 -15.0996 4.5
752
+c3.2998 42.1006 32.1992 71.4004 56 71.4004c23.7998 0 52.6992 -29.2998 56 -71.4004c0.699219 -8.5 -10.8008 -11.8994 -14.9004 -4.5l-9.5 17c-7.7002 13.7002 -19.2002 21.6006 -31.5 21.6006s-23.7998 -7.90039 -31.5 -21.6006zM362.4 160c8.19922 0 14.5 -7 13.5 -15
753
+c-7.5 -59.2002 -58.9004 -105 -121.101 -105h-13.5996c-62.2002 0 -113.601 45.7998 -121.101 105c-1 8 5.30078 15 13.5 15h228.801z" />
754
+    <glyph glyph-name="laugh-squint" unicode="&#xf59b;" horiz-adv-x="496" 
755
+d="M248 440c137 0 248 -111 248 -248s-111 -248 -248 -248s-248 111 -248 248s111 248 248 248zM389.4 50.5996c37.7998 37.8008 58.5996 88 58.5996 141.4s-20.7998 103.6 -58.5996 141.4c-37.8008 37.7998 -88 58.5996 -141.4 58.5996s-103.6 -20.7998 -141.4 -58.5996
756
+c-37.7998 -37.8008 -58.5996 -88 -58.5996 -141.4s20.7998 -103.6 58.5996 -141.4c37.8008 -37.7998 88 -58.5996 141.4 -58.5996s103.6 20.7998 141.4 58.5996zM343.6 252l33.6006 -40.2998c8.59961 -10.4004 -3.90039 -24.7998 -15.4004 -18l-80 48
757
+c-7.7998 4.7002 -7.7998 15.8994 0 20.5996l80 48c11.6006 6.7998 24 -7.7002 15.4004 -18zM134.2 193.7c-11.6006 -6.7998 -24.1006 7.59961 -15.4004 18l33.6006 40.2998l-33.6006 40.2998c-8.59961 10.2998 3.7998 24.9004 15.4004 18l80 -48
758
+c7.7998 -4.7002 7.7998 -15.8994 0 -20.5996zM362.4 160c8.19922 0 14.5 -7 13.5 -15c-7.5 -59.2002 -58.9004 -105 -121.101 -105h-13.5996c-62.2002 0 -113.601 45.7998 -121.101 105c-1 8 5.30078 15 13.5 15h228.801z" />
759
+    <glyph glyph-name="laugh-wink" unicode="&#xf59c;" horiz-adv-x="496" 
760
+d="M248 440c137 0 248 -111 248 -248s-111 -248 -248 -248s-248 111 -248 248s111 248 248 248zM389.4 50.5996c37.7998 37.8008 58.5996 88 58.5996 141.4s-20.7998 103.6 -58.5996 141.4c-37.8008 37.7998 -88 58.5996 -141.4 58.5996s-103.6 -20.7998 -141.4 -58.5996
761
+c-37.7998 -37.8008 -58.5996 -88 -58.5996 -141.4s20.7998 -103.6 58.5996 -141.4c37.8008 -37.7998 88 -58.5996 141.4 -58.5996s103.6 20.7998 141.4 58.5996zM328 284c25.7002 0 55.9004 -16.9004 59.7002 -42.0996c1.7998 -11.1006 -11.2998 -18.2002 -19.7998 -10.8008
762
+l-9.5 8.5c-14.8008 13.2002 -46.2002 13.2002 -61 0l-9.5 -8.5c-8.30078 -7.39941 -21.5 -0.399414 -19.8008 10.8008c4 25.1992 34.2002 42.0996 59.9004 42.0996zM168 224c-17.7002 0 -32 14.2998 -32 32s14.2998 32 32 32s32 -14.2998 32 -32s-14.2998 -32 -32 -32z
763
+M362.4 160c8.19922 0 14.5 -7 13.5 -15c-7.5 -59.2002 -58.9004 -105 -121.101 -105h-13.5996c-62.2002 0 -113.601 45.7998 -121.101 105c-1 8 5.30078 15 13.5 15h228.801z" />
764
+    <glyph glyph-name="meh-blank" unicode="&#xf5a4;" horiz-adv-x="496" 
765
+d="M248 440c137 0 248 -111 248 -248s-111 -248 -248 -248s-248 111 -248 248s111 248 248 248zM248 -8c110.3 0 200 89.7002 200 200s-89.7002 200 -200 200s-200 -89.7002 -200 -200s89.7002 -200 200 -200zM168 272c17.7002 0 32 -14.2998 32 -32s-14.2998 -32 -32 -32
766
+s-32 14.2998 -32 32s14.2998 32 32 32zM328 272c17.7002 0 32 -14.2998 32 -32s-14.2998 -32 -32 -32s-32 14.2998 -32 32s14.2998 32 32 32z" />
767
+    <glyph glyph-name="meh-rolling-eyes" unicode="&#xf5a5;" horiz-adv-x="496" 
768
+d="M248 440c137 0 248 -111 248 -248s-111 -248 -248 -248s-248 111 -248 248s111 248 248 248zM248 -8c110.3 0 200 89.7002 200 200s-89.7002 200 -200 200s-200 -89.7002 -200 -200s89.7002 -200 200 -200zM336 296c39.7998 0 72 -32.2002 72 -72s-32.2002 -72 -72 -72
769
+s-72 32.2002 -72 72s32.2002 72 72 72zM336 184c22.0996 0 40 17.9004 40 40c0 13.5996 -7.2998 25.0996 -17.7002 32.2998c1 -2.59961 1.7002 -5.39941 1.7002 -8.2998c0 -13.2998 -10.7002 -24 -24 -24s-24 10.7002 -24 24c0 3 0.700195 5.7002 1.7002 8.2998
770
+c-10.4004 -7.2002 -17.7002 -18.7002 -17.7002 -32.2998c0 -22.0996 17.9004 -40 40 -40zM232 224c0 -39.7998 -32.2002 -72 -72 -72s-72 32.2002 -72 72s32.2002 72 72 72s72 -32.2002 72 -72zM120 224c0 -22.0996 17.9004 -40 40 -40s40 17.9004 40 40
771
+c0 13.5996 -7.2998 25.0996 -17.7002 32.2998c1 -2.59961 1.7002 -5.39941 1.7002 -8.2998c0 -13.2998 -10.7002 -24 -24 -24s-24 10.7002 -24 24c0 3 0.700195 5.7002 1.7002 8.2998c-10.4004 -7.2002 -17.7002 -18.7002 -17.7002 -32.2998zM312 96
772
+c13.2002 0 24 -10.7998 24 -24s-10.7998 -24 -24 -24h-128c-13.2002 0 -24 10.7998 -24 24s10.7998 24 24 24h128z" />
773
+    <glyph glyph-name="sad-cry" unicode="&#xf5b3;" horiz-adv-x="496" 
774
+d="M248 440c137 0 248 -111 248 -248s-111 -248 -248 -248s-248 111 -248 248s111 248 248 248zM392 53.5996c34.5996 35.9004 56 84.7002 56 138.4c0 110.3 -89.7002 200 -200 200s-200 -89.7002 -200 -200c0 -53.7002 21.4004 -102.4 56 -138.4v114.4
775
+c0 13.2002 10.7998 24 24 24s24 -10.7998 24 -24v-151.4c28.5 -15.5996 61.2002 -24.5996 96 -24.5996s67.5 9 96 24.5996v151.4c0 13.2002 10.7998 24 24 24s24 -10.7998 24 -24v-114.4zM205.8 213.5c-5.7998 -3.2002 -11.2002 -0.700195 -13.7002 1.59961l-9.5 8.5
776
+c-14.7998 13.2002 -46.1992 13.2002 -61 0l-9.5 -8.5c-3.7998 -3.39941 -9.2998 -4 -13.6992 -1.59961c-4.40039 2.40039 -6.90039 7.40039 -6.10059 12.4004c3.90039 25.1992 34.2002 42.0996 59.7998 42.0996c25.6006 0 55.8008 -16.9004 59.8008 -42.0996
777
+c0.799805 -5 -1.7002 -10 -6.10059 -12.4004zM344 268c25.7002 0 55.9004 -16.9004 59.7998 -42.0996c0.799805 -5 -1.7002 -10 -6.09961 -12.4004c-5.7002 -3.09961 -11.2002 -0.599609 -13.7002 1.59961l-9.5 8.5c-14.7998 13.2002 -46.2002 13.2002 -61 0l-9.5 -8.5
778
+c-3.7998 -3.39941 -9.2002 -4 -13.7002 -1.59961c-4.39941 2.40039 -6.89941 7.40039 -6.09961 12.4004c3.89941 25.1992 34.0996 42.0996 59.7998 42.0996zM248 176c30.9004 0 56 -28.7002 56 -64s-25.0996 -64 -56 -64s-56 28.7002 -56 64s25.0996 64 56 64z" />
779
+    <glyph glyph-name="sad-tear" unicode="&#xf5b4;" horiz-adv-x="496" 
780
+d="M248 440c137 0 248 -111 248 -248s-111 -248 -248 -248s-248 111 -248 248s111 248 248 248zM248 -8c110.3 0 200 89.7002 200 200s-89.7002 200 -200 200s-200 -89.7002 -200 -200s89.7002 -200 200 -200zM256 144c38.0996 0 74 -16.7998 98.5 -46.0996
781
+c8.5 -10.2002 7.09961 -25.3008 -3.09961 -33.8008c-10.6006 -8.7998 -25.7002 -6.69922 -33.8008 3.10059c-15.2998 18.2998 -37.7998 28.7998 -61.5996 28.7998c-13.2002 0 -24 10.7998 -24 24s10.7998 24 24 24zM168 208c-17.7002 0 -32 14.2998 -32 32s14.2998 32 32 32
782
+s32 -14.2998 32 -32s-14.2998 -32 -32 -32zM328 272c17.7002 0 32 -14.2998 32 -32s-14.2998 -32 -32 -32s-32 14.2998 -32 32s14.2998 32 32 32zM162.4 173.2c2.7998 3.7002 8.39941 3.7002 11.1992 0c11.4004 -15.2998 36.4004 -50.6006 36.4004 -68.1006
783
+c0 -22.6992 -18.7998 -41.0996 -42 -41.0996s-42 18.4004 -42 41.0996c0 17.5 25 52.8008 36.4004 68.1006z" />
784
+    <glyph glyph-name="smile-beam" unicode="&#xf5b8;" horiz-adv-x="496" 
785
+d="M248 440c137 0 248 -111 248 -248s-111 -248 -248 -248s-248 111 -248 248s111 248 248 248zM248 -8c110.3 0 200 89.7002 200 200s-89.7002 200 -200 200s-200 -89.7002 -200 -200s89.7002 -200 200 -200zM332 135.4c8.5 10.1992 23.5996 11.5 33.7998 3.09961
786
+c10.2002 -8.5 11.6006 -23.5996 3.10059 -33.7998c-30 -36 -74.1006 -56.6006 -120.9 -56.6006s-90.9004 20.6006 -120.9 56.6006c-8.39941 10.2002 -7.09961 25.2998 3.10059 33.7998c10.2002 8.40039 25.2998 7.09961 33.7998 -3.09961
787
+c20.7998 -25.1006 51.5 -39.4004 84 -39.4004s63.2002 14.4004 84 39.4004zM136.5 237l-9.5 -17c-1.90039 -3.2002 -5.90039 -4.7998 -9.2998 -3.7002c-3.60059 1.10059 -6 4.60059 -5.7002 8.2998c3.2998 42.1006 32.2002 71.4004 56 71.4004s52.7002 -29.2998 56 -71.4004
788
+c0.299805 -3.7998 -2.09961 -7.19922 -5.7002 -8.2998c-3.09961 -1 -7.2002 0 -9.2998 3.7002l-9.5 17c-7.7002 13.7002 -19.2002 21.5996 -31.5 21.5996s-23.7998 -7.89941 -31.5 -21.5996zM328 296c23.7998 0 52.7002 -29.2998 56 -71.4004
789
+c0.299805 -3.7998 -2.09961 -7.19922 -5.7002 -8.2998c-3.09961 -1 -7.2002 0 -9.2998 3.7002l-9.5 17c-7.7002 13.7002 -19.2002 21.5996 -31.5 21.5996s-23.7998 -7.89941 -31.5 -21.5996l-9.5 -17c-1.90039 -3.2002 -5.7998 -4.7998 -9.2998 -3.7002
790
+c-3.60059 1.10059 -6 4.60059 -5.7002 8.2998c3.2998 42.1006 32.2002 71.4004 56 71.4004z" />
791
+    <glyph glyph-name="surprise" unicode="&#xf5c2;" horiz-adv-x="496" 
792
+d="M248 440c137 0 248 -111 248 -248s-111 -248 -248 -248s-248 111 -248 248s111 248 248 248zM248 -8c110.3 0 200 89.7002 200 200s-89.7002 200 -200 200s-200 -89.7002 -200 -200s89.7002 -200 200 -200zM248 168c35.2998 0 64 -28.7002 64 -64s-28.7002 -64 -64 -64
793
+s-64 28.7002 -64 64s28.7002 64 64 64zM200 240c0 -17.7002 -14.2998 -32 -32 -32s-32 14.2998 -32 32s14.2998 32 32 32s32 -14.2998 32 -32zM328 272c17.7002 0 32 -14.2998 32 -32s-14.2998 -32 -32 -32s-32 14.2998 -32 32s14.2998 32 32 32z" />
794
+    <glyph glyph-name="tired" unicode="&#xf5c8;" horiz-adv-x="496" 
795
+d="M248 440c137 0 248 -111 248 -248s-111 -248 -248 -248s-248 111 -248 248s111 248 248 248zM248 -8c110.3 0 200 89.7002 200 200s-89.7002 200 -200 200s-200 -89.7002 -200 -200s89.7002 -200 200 -200zM377.1 295.8c3.80078 -4.39941 3.90039 -11 0.100586 -15.5
796
+l-33.6006 -40.2998l33.6006 -40.2998c3.7998 -4.5 3.7002 -11 -0.100586 -15.5c-3.5 -4.10059 -9.89941 -5.7002 -15.2998 -2.5l-80 48c-3.59961 2.2002 -5.7998 6.09961 -5.7998 10.2998s2.2002 8.09961 5.7998 10.2998l80 48c5 2.90039 11.5 1.90039 15.2998 -2.5z
797
+M220 240c0 -4.2002 -2.2002 -8.09961 -5.7998 -10.2998l-80 -48c-5.40039 -3.2002 -11.7998 -1.60059 -15.2998 2.5c-3.80078 4.5 -3.90039 11 -0.100586 15.5l33.6006 40.2998l-33.6006 40.2998c-3.7998 4.5 -3.7002 11 0.100586 15.5
798
+c3.7998 4.40039 10.2998 5.5 15.2998 2.5l80 -48c3.59961 -2.2002 5.7998 -6.09961 5.7998 -10.2998zM248 176c45.4004 0 100.9 -38.2998 107.8 -93.2998c1.5 -11.9004 -7 -21.6006 -15.5 -17.9004c-22.7002 9.7002 -56.2998 15.2002 -92.2998 15.2002
799
+s-69.5996 -5.5 -92.2998 -15.2002c-8.60059 -3.7002 -17 6.10059 -15.5 17.9004c6.89941 55 62.3994 93.2998 107.8 93.2998z" />
800
+  </font>
801
+</defs></svg>

二進制
app/static/bower_components/components-font-awesome/webfonts/fa-regular-400.ttf


二進制
app/static/bower_components/components-font-awesome/webfonts/fa-regular-400.woff


二進制
app/static/bower_components/components-font-awesome/webfonts/fa-regular-400.woff2


二進制
app/static/bower_components/components-font-awesome/webfonts/fa-solid-900.eot


File diff suppressed because it is too large
+ 5034 - 0
app/static/bower_components/components-font-awesome/webfonts/fa-solid-900.svg


二進制
app/static/bower_components/components-font-awesome/webfonts/fa-solid-900.ttf


二進制
app/static/bower_components/components-font-awesome/webfonts/fa-solid-900.woff


二進制
app/static/bower_components/components-font-awesome/webfonts/fa-solid-900.woff2


tum/whitesports - Gogs: Simplico Git Service

Bez popisu

functions.photon.php 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <?php
  2. use Automattic\Jetpack\Status;
  3. /**
  4. * Generic functions using the Photon service.
  5. *
  6. * Some are used outside of the Photon module being active, so intentionally not within the module.
  7. *
  8. * @package automattic/jetpack
  9. */
  10. /**
  11. * Generates a Photon URL.
  12. *
  13. * @see https://developer.wordpress.com/docs/photon/
  14. *
  15. * @param string $image_url URL to the publicly accessible image you want to manipulate.
  16. * @param array|string $args An array of arguments, i.e. array( 'w' => '300', 'resize' => array( 123, 456 ) ), or in string form (w=123&h=456).
  17. * @param string|null $scheme URL protocol.
  18. * @return string The raw final URL. You should run this through esc_url() before displaying it.
  19. */
  20. function jetpack_photon_url( $image_url, $args = array(), $scheme = null ) {
  21. $image_url = trim( $image_url );
  22. if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) {
  23. /**
  24. * Disables Photon URL processing for local development
  25. *
  26. * @module photon
  27. *
  28. * @since 4.1.0
  29. *
  30. * @param bool false Result of Automattic\Jetpack\Status->is_offline_mode().
  31. */
  32. if ( true === apply_filters( 'jetpack_photon_development_mode', ( new Status() )->is_offline_mode() ) ) {
  33. return $image_url;
  34. }
  35. }
  36. /**
  37. * Allow specific image URls to avoid going through Photon.
  38. *
  39. * @module photon
  40. *
  41. * @since 3.2.0
  42. *
  43. * @param bool false Should the image be returned as is, without going through Photon. Default to false.
  44. * @param string $image_url Image URL.
  45. * @param array|string $args Array of Photon arguments.
  46. * @param string|null $scheme Image scheme. Default to null.
  47. */
  48. if ( false !== apply_filters( 'jetpack_photon_skip_for_url', false, $image_url, $args, $scheme ) ) {
  49. return $image_url;
  50. }
  51. /**
  52. * Filter the original image URL before it goes through Photon.
  53. *
  54. * @module photon
  55. *
  56. * @since 1.9.0
  57. *
  58. * @param string $image_url Image URL.
  59. * @param array|string $args Array of Photon arguments.
  60. * @param string|null $scheme Image scheme. Default to null.
  61. */
  62. $image_url = apply_filters( 'jetpack_photon_pre_image_url', $image_url, $args, $scheme );
  63. /**
  64. * Filter the original Photon image parameters before Photon is applied to an image.
  65. *
  66. * @module photon
  67. *
  68. * @since 1.9.0
  69. *
  70. * @param array|string $args Array of Photon arguments.
  71. * @param string $image_url Image URL.
  72. * @param string|null $scheme Image scheme. Default to null.
  73. */
  74. $args = apply_filters( 'jetpack_photon_pre_args', $args, $image_url, $scheme );
  75. if ( empty( $image_url ) ) {
  76. return $image_url;
  77. }
  78. $image_url_parts = wp_parse_url( $image_url );
  79. // Unable to parse.
  80. if ( ! is_array( $image_url_parts ) || empty( $image_url_parts['host'] ) || empty( $image_url_parts['path'] ) ) {
  81. return $image_url;
  82. }
  83. if ( is_array( $args ) ) {
  84. // Convert values that are arrays into strings.
  85. foreach ( $args as $arg => $value ) {
  86. if ( is_array( $value ) ) {
  87. $args[ $arg ] = implode( ',', $value );
  88. }
  89. }
  90. // Encode values.
  91. // See https://core.trac.wordpress.org/ticket/17923 .
  92. $args = rawurlencode_deep( $args );
  93. }
  94. // Don't photon-ize WPCOM hosted images -- we can serve them up from wpcom directly.
  95. $is_wpcom_image = false;
  96. if ( wp_endswith( strtolower( $image_url_parts['host'] ), '.files.wordpress.com' ) ) {
  97. $is_wpcom_image = true;
  98. if ( isset( $args['ssl'] ) ) {
  99. // Do not send the ssl argument to prevent caching issues.
  100. unset( $args['ssl'] );
  101. }
  102. }
  103. /** This filter is documented below. */
  104. $custom_photon_url = apply_filters( 'jetpack_photon_domain', '', $image_url );
  105. $custom_photon_url = esc_url( $custom_photon_url );
  106. // You can't run a Photon URL through Photon again because query strings are stripped.
  107. // So if the image is already a Photon URL, append the new arguments to the existing URL.
  108. // Alternately, if it's a *.files.wordpress.com url, then keep the domain as is.
  109. if (
  110. in_array( $image_url_parts['host'], array( 'i0.wp.com', 'i1.wp.com', 'i2.wp.com' ), true )
  111. || wp_parse_url( $custom_photon_url, PHP_URL_HOST ) === $image_url_parts['host']
  112. || $is_wpcom_image
  113. ) {
  114. $photon_url = add_query_arg( $args, $image_url );
  115. return jetpack_photon_url_scheme( $photon_url, $scheme );
  116. }
  117. /**
  118. * Allow Photon to use query strings as well.
  119. * By default, Photon doesn't support query strings so we ignore them and look only at the path.
  120. * This setting is Photon Server dependent.
  121. *
  122. * @module photon
  123. *
  124. * @since 1.9.0
  125. *
  126. * @param bool false Should images using query strings go through Photon. Default is false.
  127. * @param string $image_url_parts['host'] Image URL's host.
  128. */
  129. if ( ! apply_filters( 'jetpack_photon_any_extension_for_domain', false, $image_url_parts['host'] ) ) {
  130. // Photon doesn't support query strings so we ignore them and look only at the path.
  131. // However some source images are served via PHP so check the no-query-string extension.
  132. // For future proofing, this is an excluded list of common issues rather than an allow list.
  133. $extension = pathinfo( $image_url_parts['path'], PATHINFO_EXTENSION );
  134. if ( empty( $extension ) || in_array( $extension, array( 'php', 'ashx' ), true ) ) {
  135. return $image_url;
  136. }
  137. }
  138. $image_host_path = $image_url_parts['host'] . $image_url_parts['path'];
  139. /*
  140. * Figure out which CDN subdomain to use.
  141. *
  142. * The goal is to have the same subdomain for any particular image to prevent multiple runs resulting in multiple
  143. * images needing to be downloaded by the browser.
  144. *
  145. * We are providing our own generated value by taking the modulus of the crc32 value of the URL.
  146. *
  147. * Valid values are 0, 1, and 2.
  148. */
  149. $subdomain = abs( crc32( $image_host_path ) % 3 );
  150. /**
  151. * Filters the domain used by the Photon module.
  152. *
  153. * @module photon
  154. *
  155. * @since 3.4.2
  156. *
  157. * @param string https://i{$subdomain}.wp.com Domain used by Photon. $subdomain is a random number between 0 and 2.
  158. * @param string $image_url URL of the image to be photonized.
  159. */
  160. $photon_domain = apply_filters( 'jetpack_photon_domain', "https://i{$subdomain}.wp.com", $image_url );
  161. $photon_domain = trailingslashit( esc_url( $photon_domain ) );
  162. $photon_url = $photon_domain . $image_host_path;
  163. /**
  164. * Add query strings to Photon URL.
  165. * By default, Photon doesn't support query strings so we ignore them.
  166. * This setting is Photon Server dependent.
  167. *
  168. * @module photon
  169. *
  170. * @since 1.9.0
  171. *
  172. * @param bool false Should query strings be added to the image URL. Default is false.
  173. * @param string $image_url_parts['host'] Image URL's host.
  174. */
  175. if ( isset( $image_url_parts['query'] ) && apply_filters( 'jetpack_photon_add_query_string_to_domain', false, $image_url_parts['host'] ) ) {
  176. $photon_url .= '?q=' . rawurlencode( $image_url_parts['query'] );
  177. }
  178. if ( $args ) {
  179. if ( is_array( $args ) ) {
  180. $photon_url = add_query_arg( $args, $photon_url );
  181. } else {
  182. // You can pass a query string for complicated requests but where you still want CDN subdomain help, etc.
  183. $photon_url .= '?' . $args;
  184. }
  185. }
  186. if ( isset( $image_url_parts['scheme'] ) && 'https' === $image_url_parts['scheme'] ) {
  187. $photon_url = add_query_arg( array( 'ssl' => 1 ), $photon_url );
  188. }
  189. return jetpack_photon_url_scheme( $photon_url, $scheme );
  190. }
  191. /**
  192. * Add an easy way to photon-ize a URL that is safe to call even if Jetpack isn't active.
  193. *
  194. * See: https://jetpack.com/2013/07/11/photon-and-themes/
  195. */
  196. add_filter( 'jetpack_photon_url', 'jetpack_photon_url', 10, 3 );
  197. /**
  198. * WordPress.com
  199. *
  200. * If a cropped WP.com-hosted image is the source image, have Photon replicate the crop.
  201. */
  202. add_filter( 'jetpack_photon_pre_args', 'jetpack_photon_parse_wpcom_query_args', 10, 2 );
  203. /**
  204. * Parses WP.com-hosted image args to replicate the crop.
  205. *
  206. * @param mixed $args Args set during Photon's processing.
  207. * @param string $image_url URL of the image.
  208. * @return array|string Args for Photon to use for the URL.
  209. */
  210. function jetpack_photon_parse_wpcom_query_args( $args, $image_url ) {
  211. $parsed_url = wp_parse_url( $image_url );
  212. if ( ! $parsed_url ) {
  213. return $args;
  214. }
  215. $image_url_parts = wp_parse_args(
  216. $parsed_url,
  217. array(
  218. 'host' => '',
  219. 'query' => '',
  220. )
  221. );
  222. if ( '.files.wordpress.com' !== substr( $image_url_parts['host'], -20 ) ) {
  223. return $args;
  224. }
  225. if ( empty( $image_url_parts['query'] ) ) {
  226. return $args;
  227. }
  228. $wpcom_args = wp_parse_args( $image_url_parts['query'] );
  229. if ( empty( $wpcom_args['w'] ) || empty( $wpcom_args['h'] ) ) {
  230. return $args;
  231. }
  232. // Keep the crop by using "resize".
  233. if ( ! empty( $wpcom_args['crop'] ) ) {
  234. if ( is_array( $args ) ) {
  235. $args = array_merge( array( 'resize' => array( $wpcom_args['w'], $wpcom_args['h'] ) ), $args );
  236. } else {
  237. $args = 'resize=' . rawurlencode( absint( $wpcom_args['w'] ) . ',' . absint( $wpcom_args['h'] ) ) . '&' . $args;
  238. }
  239. } else {
  240. if ( is_array( $args ) ) {
  241. $args = array_merge( array( 'fit' => array( $wpcom_args['w'], $wpcom_args['h'] ) ), $args );
  242. } else {
  243. $args = 'fit=' . rawurlencode( absint( $wpcom_args['w'] ) . ',' . absint( $wpcom_args['h'] ) ) . '&' . $args;
  244. }
  245. }
  246. return $args;
  247. }
  248. /**
  249. * Sets the scheme for a URL
  250. *
  251. * @param string $url URL to set scheme.
  252. * @param string $scheme Scheme to use. Accepts http, https, network_path.
  253. *
  254. * @return string URL.
  255. */
  256. function jetpack_photon_url_scheme( $url, $scheme ) {
  257. if ( ! in_array( $scheme, array( 'http', 'https', 'network_path' ), true ) ) {
  258. if ( preg_match( '#^(https?:)?//#', $url ) ) {
  259. return $url;
  260. }
  261. $scheme = 'http';
  262. }
  263. if ( 'network_path' === $scheme ) {
  264. $scheme_slashes = '//';
  265. } else {
  266. $scheme_slashes = "$scheme://";
  267. }
  268. return preg_replace( '#^([a-z:]+)?//#i', $scheme_slashes, $url );
  269. }
  270. /**
  271. * A wrapper for PHP's parse_url, prepending assumed scheme for network path
  272. * URLs. PHP versions 5.4.6 and earlier do not correctly parse without scheme.
  273. *
  274. * WP ships with a wrapper for parse_url, wp_parse_url, that should be used instead.
  275. *
  276. * @see https://php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-changelog
  277. * @deprecated 7.8.0 Use wp_parse_url instead.
  278. *
  279. * @param string $url The URL to parse.
  280. * @param integer $component Retrieve specific URL component.
  281. * @return mixed Result of parse_url
  282. */
  283. function jetpack_photon_parse_url( $url, $component = -1 ) {
  284. _deprecated_function( 'jetpack_photon_parse_url', 'jetpack-7.8.0', 'wp_parse_url' );
  285. return wp_parse_url( $url, $component );
  286. }
  287. add_filter( 'jetpack_photon_skip_for_url', 'jetpack_photon_banned_domains', 9, 2 );
  288. /**
  289. * Check to skip Photon for a known domain that shouldn't be Photonized.
  290. *
  291. * @param bool $skip If the image should be skipped by Photon.
  292. * @param string $image_url URL of the image.
  293. *
  294. * @return bool Should the image be skipped by Photon.
  295. */
  296. function jetpack_photon_banned_domains( $skip, $image_url ) {
  297. $banned_host_patterns = array(
  298. '/^chart\.googleapis\.com$/',
  299. '/^chart\.apis\.google\.com$/',
  300. '/^graph\.facebook\.com$/',
  301. '/\.fbcdn\.net$/',
  302. '/\.paypalobjects\.com$/',
  303. '/\.dropbox\.com$/',
  304. '/\.cdninstagram\.com$/',
  305. '/^(commons|upload)\.wikimedia\.org$/',
  306. );
  307. $host = wp_parse_url( $image_url, PHP_URL_HOST );
  308. foreach ( $banned_host_patterns as $banned_host_pattern ) {
  309. if ( 1 === preg_match( $banned_host_pattern, $host ) ) {
  310. return true;
  311. }
  312. }
  313. return $skip;
  314. }
  315. /**
  316. * Jetpack Photon - Support Text Widgets.
  317. *
  318. * @access public
  319. * @param string $content Content from text widget.
  320. * @return string
  321. */
  322. function jetpack_photon_support_text_widgets( $content ) {
  323. if ( class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' ) ) {
  324. return Jetpack_Photon::filter_the_content( $content );
  325. }
  326. return $content;
  327. }
  328. add_filter( 'widget_text', 'jetpack_photon_support_text_widgets' );