Forum

Thread tagged as: Blog

Cause of a missing 'Add Asset' button?

I have a strange problem where my customer is reporting she can't see the 'Add Asset' button during the process of adding an image to a blog entry. The weird thing is the button appears fine on another Perch Blog/Site she has. Both sites are the same Perch and Blog release (the latest) and the same version of PHP.

I have set up another username for myself with the same 'Editor' permissions and I can see the 'Add Asset' button. I've tried it in Chrome, Firefox and Safari. My customer is using 'Firefox 47.0 - Mozilla Firefox for Linux Mint 1.0'. My thought was therefore that its the browser. But she's using the same browser to update the blog on her other site and that works fine. She doesn't have Chrome on the PC she has with her, so will be looking at this more at the end of the week.

So, my question is to ask what lack of role settings would stop the 'Add Asset' button from appearing? I have both the assets permission boxes ticked and all the blog boxes ticked.

Graham Street

Graham Street 17 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Which add asset button are you referring to? If I know where you're seeing/not seeing it I can have a look.

Its the one that appears on the 'asset slider' that comes in from the right side. But 'hold' for a while as I think I've just accidentally seen the problem happen for myself. But, annoyingly, I now can't recreate it! I was logged in as an admin too. So I'm going to methodically try various things to see if I can pinpoint when this happens.

1 hour later ... I tried various combinations of logging off/on and editing blog posts already containing images and not containing images. I cannot recreate the point where the 'Add Asset' button isn't visible. I'm working on/off that site in the coming days so will just keep a watch for it happening again. I might need to wait until Friday when my customer is back at base so that she can try another browser/computer to see if the problem is there too.

I've just managed to recreate this, but can't repeat it. I left the site alone for 6 hours and then ... logged into Perch Admin (as an admin) ... went to the Blog, picked a post to edit ... clicked 'select or upload an image'. The Assets slider has the 'Add Asset' button missing. At this point I took a copy of the page source code of Perch Admin. When I reloaded the page, the 'Add Asset' button appeared.

In the source code I found these entries at the foot of the code. And I recognised the code for 'auto-minify of Javascript' - one of the performance options in Cloudflare ...

<script data-rocketsrc="/perch/core/assets/js/jquery-1.11.3.min.js" type="text/rocketscript"></script>
<script data-rocketsrc="/perch/core/assets/js/jquery-ui.js?v=2.8.31" type="text/rocketscript"></script>
<script data-rocketsrc="/perch/core/assets/js/perch.min.js?v=2.8.31" type="text/rocketscript"></script>
    <script data-rocketsrc="/perch/core/assets/js/chosen.jquery.min.js" type="text/rocketscript"></script>
    <script data-rocketsrc="/perch/core/assets/js/categories.js" type="text/rocketscript"></script>
<script type="text/rocketscript">
    Perch.token = 'b834041ca83b7bdb7bb3a6dc35e68f70';
    Perch.path = '/perch';
    Perch.version = '2.8.31';
    </script>
        <script data-rocketsrc="/perch/addons/plugins/editors/markitup/jquery.markitup.js" type="text/rocketscript"></script>
        <script data-rocketsrc="/perch/addons/plugins/editors/markitup/config.js" type="text/rocketscript"></script>
        <script data-rocketsrc="/perch/addons/plugins/editors/markitup/image_upload/image_upload.js" type="text/rocketscript"></script>
        <script data-rocketsrc="/perch/core/assets/js/jquery.form.min.js" type="text/rocketscript"></script>
        <link rel="stylesheet" href="/perch/addons/plugins/editors/markitup/css/markitup.min.css" />
<!-- Custom CSS/JavaScript --></body>
</html>

Thinking this could be the cause of the possible delayed appearance of the 'Add Asset' button, I have now disabled Cloudflare for this site. I'll try editing again in an hour or so, and will ask my customer to try to edit blog posts to add images this evening and see if the problem's gone away.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Let us know how you get on.

I can see (in the /resources/blog folder) that my customer has recently loaded two images. I haven't actually heard from her yet, but this looks promising as she was unable to do this. Once I hear from her, I will enable Cloudflare again, but not set the 'auto-minify' option for Javascript. We'll then continue to see if things carry on working properly.

I believe I've identified the cause of the problem. Its an optional feature of CloudFlare called 'Rocket Loader' (not the 'auto-minify' option mentioned earlier). This 'Rocket Loader' feature is in beta and had been enabled for this website. Quoting the CloudFlare website this is what it does and it obviously interferes with the scripts in Perch Admin ...

Rocket Loader improves page load times by:

  • Decreasing the number of network requests by bundling JavaScript files, even third party resources, to avoid slowing down page rendering

  • Asynchronously loading scripts, including third party scripts, so that they do not block the content of your page from loading immediately

  • Caching scripts locally (using LocalStorage, available on most browsers and smart phones) so they aren't refetched unless necessary

So, for this site, Cloudflare IS enabled again, as are the auto-minify options. But Rocket Loader is disabled. So far, all is well and everything's working the way its supposed to.