Colonel_mortis Posted January 7, 2023 Posted January 7, 2023 To reproduce: (Prerequisites: lazy loading is enabled (on by default), and the default disk storage location is used for attachments) Attach an image to a post Look at that post in the DB - it should look something like <img class="ipsImage ipsImage_thumbnailed" data-fileid="1" data-ratio="75.00" width="640" alt="foo.jpg" data-src="<fileStore.core_Attachment>/monthly_2022_10/foo.jpg" src="<___base_url___>/applications/core/interface/js/spacer.png" /> Edit the post (don't need to change anything) Look at the post again in the DB - it should now look something like <img alt="foo.jpg" class="ipsImage ipsImage_thumbnailed" data-fileid="1" data-ratio="75.00" width="640" data-src="<___base_url___>/uploads/monthly_2022_10/foo.jpg" src="<___base_url___>/applications/core/interface/js/spacer.png" /> Notice that the data-src has changed from <fileStore.core_Attachment>/monthly_2022_10/foo.jpg to <___base_url___>/uploads/monthly_2022_10/foo.jpg, so it is no longer agnostic of the backing file store Moving the attachments filestore will now cause these images to point to the wrong place. This is because in \IPS\Text\Parser::_parseImgElement, you have /* Lazy-loaded? */ $srcAttribute = ( $element->hasAttribute( 'src' ) AND $element->hasAttribute( 'data-src' ) ) ? 'data-src' : 'src'; // ... /* Or an attachment? */ elseif ( $attachment = static::_getAttachment( $element->getAttribute($srcAttribute ), $element->hasAttribute('data-fileid') ? $element->getAttribute('data-fileid') : NULL ) ) { $file = $this->_getFile( 'core_Attachment', $element->getAttribute( $srcAttribute ) ); $element->setAttribute( 'data-fileid', $attachment['attach_id'] ); $element->setAttribute( 'src', str_replace( array( 'http:', 'https:' ), '', str_replace( static::$fileObjectClasses['core_Attachment']->baseUrl(), '{fileStore.core_Attachment}', $element->getAttribute( $srcAttribute ) ) ) ); the last line there is setting the 'src' attribute, when in fact it should be setting $srcAttribute. The src attribute is subsequently discarded to replace with the lazy load placeholder. This works for new posts because $srcAttribute is 'src' there, but when editing posts (with lazy loading enabled) it is actually data-src. SeNioR- 1
Jim M Posted January 7, 2023 Posted January 7, 2023 Thank you for bringing this issue to our attention! I can confirm this should be further reviewed and I have logged an internal bug report for our development team to investigate and address as necessary, in a future maintenance release.
Solution Marc Posted March 10, 2023 Solution Posted March 10, 2023 Just a quick update to let you know that this issue was resolved in the recent 4.7.8 release of our platform. Please upgrade your site to resolve this issue. If you are still seeing any issues after upgrading to this version, please let us know.
Recommended Posts